in reply to How come @_ gets changed here?

No, @_ is an alias to the sub's arguments. That's how things like chomp work:

sub my_chomp { $_[0] =~ s/\r?\n\z//sm; } my $var = "foo\n"; my_chomp $var; print "[[$foo]]\n";

perlsub says:

The array @_ is a local array, but its elements are aliases for the actual scalar parameters.