Note, of course, that code can be made to work with either @_ or @ARGV depending on whether it's inside or outside a sub: just use shift:
my $arg1 = shift;
:-)
local @ARGV = @_;
Normally there's no need to do this, of course, and is contra-idiomatic. But there is one situation when it is called for: when you are going to be calling some other function which expects its inputs in @ARGV. Example: Getopt::Long.
use Getopt::Long;
sub do_awesome_things
{
local @ARGV = @_;
GetOptions(
'files=s' => \my @files,
'verbose!' => \my $verbose,
);
warn "Going to process files @files. "
. "Verbose is ".( $verbose ? 'ON' : 'OFF' ).".\n";
}
do_awesome_things -v => -file => 'foo.txt', -file => 'bar.txt';
Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.