[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] The Perl Golf Apocalypse Experience



>>>>> "Tim" == Tim Ayers <tayers@bridge.com> writes:

Tim>  + "Backup" files in a directory tree to *.bak

Tim>     perl -e'sub x{($a)=@_;(-f)?(open(A,$_),open(B,">$_.bak"),print B<A>):x($_)for<$a/*>}x(shift)' <directory>

Even with whitespace, this is shorter:

  perl -MFile::Find -pi.bak -e 'BEGIN { find sub { push @ARGV, $File::Find::name }, shift }' <directory>

:-)


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe