in reply to quick "open->close" file

If (as your example implies) the filename is passed as the first command line argument, then you can use the empty file input operator (<>) to read from it.

my @found = grep { something } <>;
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: quick "open->close" file
by bugsbunny (Scribe) on Aug 06, 2003 at 13:56 UTC
    nope, the filename is not passed in @ARGV.. what comes in @ARGV is for what to search in files..
      the filename is not passed in @ARGV

      Of course there's nothing to stop you putting it there :)

      my @args = @ARGV; @ARGV = 'filename.txt'; my @found = grep { /^args[0]/ } <>;
      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg