in reply to Re: Writing unix-style filters
in thread Writing unix-style filters

 chomp( @files = @ARGV ? grep { -f $_ } @ARGV : <> );
This chomps after you do the file test, with the newline not yet removed. So, it will just produce an empty array, when reading the file list from the input, because -f $_ will always return false.

Replies are listed 'Best First'.
Re^3: Writing unix-style filters
by jdporter (Paladin) on Apr 11, 2007 at 15:38 UTC

    No; actually, it will not, because the -f test operator here is not being applied to the strings which are returned from the <>. Perhaps it should be; in which case you'd have a very good point.

    chomp( @files = @ARGV ? @ARGV : <> ); @files = grep { -f $_ } @files;
    A word spoken in Mind will reach its own level, in the objective world, by its own weight