Drieux wrote: > foreach my $file (@ARGV) { # for everything we see on the command line > # let us assume it is a file for simplicity > if ( -f $file ) { > open(FH, "$file"); # normally we want to die > print $_ while(<FH>); # silly but a one liner > # could have been while(<FH>) { print $_ ;} > # but that always makes me think that the > # code is winking at me... > close(FH); > }else{ > print "cat: $file: No such file or directory\n"; > } > }
Heres a cool trick that perl has: while (<>) { print(); } is automagically transformed by the interpreter to: unshift(@ARGV, '-') unless @ARGV; while ($ARGV = shift) { open(ARGV, $ARGV); while (<ARGV>) { print(); } } see http://www.perldoc.com/perl5.6.1/pod/perlop.html#I-O-Operators Todd W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]