http://qs321.pair.com?node_id=448583


in reply to UN*X ls, sed, cat... in Perl

I was just curious why you would do this:
@files = reverse (sort { $files{$a} <=> $files{$b} } keys %files);
instead of this:
@files = sort { $files{$b} <=> $files{$a} } keys %files;
As for the "2A" example, you could simplify that to a single system call:
my $redirect = ( $TRACE < 2 ) ? '>' : '| tee'; system( "sed s/{author}.*//g <$file $redirect ${file}1.txt";
The trick there is that when you pipe to "tee filename", output is written to both stdout and to filename; and the stdout from "system()" is the same as the perl script's STDOUT, so you'll see it.