Perl passes by alias, so using @_ instead of @ARGV will not prevent worries about modifying the global @ARGV. Options are to make a lexical copy (my @args = @ARGV) or to localise (local @ARGV = @ARGV).
use strict;
use warnings;
print "1: @ARGV\n";
foo(@ARGV);
print "3: @ARGV\n";
sub foo {
print "2a: @_\n";
$_[0] = "foobar";
print "2b: @_\n";
}
(Note however that the elements are aliased indivualluy into @_ not the whole array, so if @ARGV is empty there will be no modification as you are then adding a new element to @_ instead of modifying an element in @ARGV through @_.)
--
integral, resident of freenode's #perl