John W. Krahn wrote:
Kelly Jones wrote:
I did this in tcsh:
perl -le 'exit(2); sub END {system("date");}' ; echo $status
Mon May 17 11:09:43 MDT 2010
0
In other words, the return value of the date command in an END subroutine
overrides my desired exit value.
How do I fix this? I want to tell Perl: if I explicitly do exit($foo), I
want the script to exit with status $foo?
This is probably what you want:
$ perl -le' END { system "date"; $? = 2 } ' ; echo $?
Mon May 17 11:01:37 PDT 2010
2
Or don't use something that sets $? in the END block:
$ perl -le' exit 2; END { print scalar localtime } ' ; echo $?
Mon May 17 11:19:30 2010
2
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/