[Israel.pm] gzip / gunzip

sawyer x xsawyerx at gmail.com
Sun Apr 12 02:15:10 PDT 2009


Hey Chanan.

This is a bit late, but I hope it will be useful for you.

- You can use Archive::Tar to create and manipulate tar archives
completely independent of whatever library the computer has or doesn't
have. It doesn't use any external libraries and does not even have any
C parts. It's pure Perl, which means that it's guaranteed to be slower
than any C library or application BUT it will work on windows (where
you don't even have tar) and will be quite suitable for regular files
and if you're not too worried about speed, you're good to go with it.

- I would recommend on GNU/Linux or any other Unix-compatible
environment to use Net::OpenSSH. It depends on openssh binaries (which
generally isn't that good of an idea) but it's much faster than
Net::SSH::Perl and Net::SFTP (which uses Net::SSH::Perl). They both
have a LOT of dependencies on external libraries and modules.
Net::OpenSSH is clean, very fast and highly adaptable. The developer
is very active on it as well, and accepts patches, comments and bug
reports and works hard on the module. I've contacted him a few times,
and I started moving all my projects to Net::OpenSSH. I can provide
you with code which streamlines scp copies straight into a tar archive
or from one. Something like tar czv files | ssh user at host tar zxv -C
location/.

- If you need full compatibility with Windows, you could try
Net::SSH::Perl but my warning is that it would a pain to install the
libraries. I'm not really sure it's possible, but then again, I
haven't tried so I don't know.

- While I'm bombarding you with tips and advices (sorry :), I would
recommend checking out File::Spec and File::Basename. I use them often
and they provide you with OS compatible way of figure out paths to
files. It can analyze files and provide clear paths to those files.
Here is an example I use sometimes:

use English '-no_match_vars'; # so I could use $PROGRAM_NAME instead of $0.
use File::Spec;
use File::Basename;

my $docroot = dirname($PROGRAM_NAME); # from File::Basename
my $db_filename = 'example.sqlite';
my $db_path = File::Spec->catfile( $docroot, $db_filename ); # this
returns the string path

---

This way, no matter where you run the file from, it will use the
correct path to the folder the file is in.
Just a tip that might help.

Good luck!
Sawyer.


More information about the Perl mailing list