# use strict; # UPDATE: that was commented as spotted by Eily ( see below) # use warnings; # UPDATE BEGIN{print "inside BEGIN \@ARGV is [@ARGV]\n"} my $test='original value'; print "inside main \@ARGV is [@ARGV] and \$test is [$test]\n"; #### perl -s simple.pl -test=SET_VIA_-s arg1 inside BEGIN @ARGV is [arg1] and $test is [SET_VIA_-s] inside main @ARGV is [arg1] and $test is [original value] #### perl -MO=Deparse -s simple.pl -test=SET_VIA_-s arg1 inside BEGIN @ARGV is [arg1] and $test is [SET_VIA_-s] sub BEGIN { print "inside BEGIN \@ARGV is [@ARGV] and \$test is [$test]\n"; } my $test = 'original value'; print "inside main \@ARGV is [@ARGV] and \$test is [$test]\n"; simple.pl syntax OK #### perl -se "BEGIN{print qq(inside BEGIN \@ARGV is [@ARGV]\n)};print qq(inside main \@ARGV is [@ARGV] and \$test is [$test]\n);" -test=SET_VIA_-s arg1 inside BEGIN @ARGV is [arg1] Can't modify constant item in scalar assignment at -e line 2, near "SET_VIA_-s" syntax error at -e line 2, near "SET_VIA_-s" Execution of -e aborted due to compilation errors. #### perl -se "BEGIN{print qq(inside BEGIN \@ARGV is [@ARGV]\n)};print qq(inside main \@ARGV is [@ARGV] and \$test is [$test]\n);" -- -test=SET_VIA_-s arg1 inside BEGIN @ARGV is [arg1] inside main @ARGV is [arg1] and $test is [SET_VIA_-s] #### perl -se "use strict; use warnings;BEGIN{print qq(inside BEGIN \@ARGV is [@ARGV]\n)}my $test='originalvalue';print qq(inside main \@ARGV is [@ARGV] and \$test is [$test]\n);" -- -test=SET_VIA_-s arg1 inside BEGIN @ARGV is [arg1] inside main @ARGV is [arg1] and $test is [original value] #### perl -se "'A'=~/(A)/;print $1 " -- -1=OUCH! OUCH! perl -se "'A'=~/(A)/;print qq($1\n)" -- -1=OUCH! A