in reply to Writing unix-style filters
I think your solution is correct, but your actual implementation could be more succinct.
This:
could (and arguably should) be written as@files = map { -f $_ ? $_ : () } @ARGV;
@files = grep { -f $_ } @ARGV;
This:
could be written aswhile ( <> ) { chomp; push @files, $_; }
though you might have a concern if the file list is huge, relative to your available memory. :-)chomp( @files = <> );
Ultimately, the whole chunk of code could be written as
chomp( @files = @ARGV ? grep { -f $_ } @ARGV : <> );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Writing unix-style filters
by bart (Canon) on Apr 11, 2007 at 11:18 UTC | |
by jdporter (Paladin) on Apr 11, 2007 at 15:38 UTC |