Looking at your code, I see some things that can be simplified immensely :

Pulling apart the string from localtime() and then piecing it together again is ingenious, but the POSIX module has a really useful routine, strftime(), which formats times very nicely. Other modules, like the DateTime module, also provide this.
You can replace the top part of your script by the following lines :

use POSIX; my $ext = strftime "%Y%m%d%H%M", localtime;

Your parameter parsing will allow for weird things happening if there is a file -c in your directory.
If you want to have nicer command line handling, turn to GetOpt::Long, at least I would recommend adding a second switch -- to turn off command line parameter processing and moving the command line processing out of the loop :

my $compress_files; if ($ARGV[0] eq '-c') { $compress_files = shift @ARGV; }; foreach (@ARGV) { ... };

The program does not give a reason why exactly it failed when opening / creating a file fails. This is bad.

# OPEN THE ORIGINAL FILE die "Can't open file for reading : $!\n" unless open(INFILE,"<$_"); # OPEN THE NEW FILE die "Can't open file for writing : $!\n" unless open(OUTFILE,">$arcfile");

The program won't work on Windows as you are not setting binmode and thus, the files to be copied will be truncated at the first ^Z byte encountered in the file. This is not truly much of a concern for you, as you intend your script to be running under Unix, but knowing and caring about binmode dosen't hurt :

# OPEN THE ORIGINAL FILE die "Can't open file for reading : $!\n" unless open(INFILE,"<$_"); binmode INFILE; # OPEN THE NEW FILE die "Can't open file for writing : $!\n" unless open(OUTFILE,">$arcfile"); binmode OUTFILE;

Of course, you could also use File::Copy or File::NCopy to copy the files, alleviating you from caring about these details.

Documentation in the POD is cool. Take a look at Pod::Usage to reuse that documentation for your help text.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: archive UNIX files by Corion
in thread archive UNIX files by draconis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.