in reply to How would you do it? Re ARGV, fundamentally!

I'd just break it up:
my ($weird, @rest) = @ARGV; @ARGV = $weird; while (<>) { ... } @ARGV = @rest; while (<>) { ... }
I set @ARGV in programs all the time. There's nothing sacred about it.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: How would you do it? Re ARGV, fundamentally!
by blazar (Canon) on Jul 19, 2005 at 11:47 UTC
      I may be seen as the poster-boy for "make it shorter", but this line:
      local @ARGV=shift;
      has a huge pile o' magic going on in it. While I might use it in a program, it deserves a comment line alongside it, explaining that the "shift" on the right side is using the old @ARGV, before the new local @ARGV is created.

      No, in production code, I'd probably write it like I showed upthread. Yours is full of magic.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.