in reply to Scope of ARGV

Are you sure you don't empty @ARGV before trying to use it in the sub? What you say doesn't appear to be true.

>perl -E"Foo::foo(); package Foo; sub foo { say for @ARGV }" a b c a b c

@ARGV is global, even using it's unqualified name. You could also use its fully qualified name, but it's not necessary.

>perl -E"Foo::foo(); package Foo; sub foo { say for @::ARGV }" a b c a b c

@::ARGV is also known as @main::ARGV.

Replies are listed 'Best First'.
Re^2: Scope of ARGV
by Anonymous Monk on Nov 28, 2011 at 19:36 UTC

    My mistake. I was doing a call to "getopts" , forgetting that it strips ARGV clean. Thanks, John Bobinyec