in reply to Command line Perl for sysadmins

Goo article .. I had few comments though (might be biased from a perl guy side instead of a sysadmin side ;) ):
One last note, of an additional technique I personally find useful -- just use perl to generate the shell commands, much like xargs. For example:
# perl -e 'for(<access_log.*>){$a = $_; s/log/log.old/; `cp $a $_`}' ls access_log.* | perl -pe 'chomp; $f0 = $_; s/log/log.old/; $_="cp $f +0 $_\n"' # note: don't use $a # other ways to write it: # | perl -lne 'chomp; print "cp $_ $_.old"' # | perl -pe 's/.+/cp $& $&.old/'
Now, that can be previewed to make sure it's right, and then either redirected into a file and run as a shell script (which has the advantage of doubling as a log of what was done), or the output can be copy/pasted into the shell or piped to bash. I also use this approach often to generate SQL commands ... e.g. take a data file and create INSERT or UPDATE statements.