On Feb 13, 2008 2:57 PM, ciwei <[EMAIL PROTECTED]> wrote: snip > so why the order of -n -e switch make the differience? > this is perl 5.8.4. > Thanks snip
This is true in all versions of Perl. It is becuase you are allowed to have more than one -e option: perl -e 'print "read ";' -e 'print "the ";' -e 'print "fine ";' -e 'print "manual\n";' If you look at the syntax in perlrun* you will see that -e must be followed by a string. The letter n is being used as the string, so you program looks like this: #!/usr/bin/perl n and it is being passed "print if /SUNW/" in $ARGV[0]. A constant is a valid Perl program (n is a bareword, so it is being treated as "n" by the parser), but it doesn't do anything. You can see this more clearly by turning off barewords with the strict** pragma: perl -Mstrict -en 'print if /SUNW/' Bareword "n" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors. * perldoc perlrun or http://perldoc.perl.org/perlrun.html#SYNOPSIS ** perldoc strict or http://perldoc.perl.org/strict.html -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/