timpoiko has asked for the wisdom of the Perl Monks concerning the following question:
timpoiko@ats:~$ cat test.pl
When I ran this code, it printed exactly what I expected:#!/usr/bin/perl use strict; use warnings; my $tmp = 2; my $var = 3; #Is $var greater than $tmp? print $var > $tmp ? "yes" : "no"; print "\n"; exit $var > $tmp ? 1 : 0;
timpoiko@ats:~$ perl test.pl yesBut however, the return value was completely unexpected:
timpoiko@ats:~$ echo $? 3What went wrong? perldoc -f exit says that exit evaluates EXPR and exits immediately with that value. My operating system is Debian testing (Jessie).
timpoiko@ats:~$ perl -v This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi (with 41 registered patches, see perl -V for more detail)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exit EXPR?
by AppleFritter (Vicar) on Jul 15, 2014 at 10:17 UTC | |
by BillKSmith (Monsignor) on Jul 15, 2014 at 13:58 UTC | |
|
Re: exit EXPR?
by Anonymous Monk on Jul 15, 2014 at 10:39 UTC | |
|
Re: exit EXPR?
by Anonymous Monk on Jul 15, 2014 at 09:55 UTC | |
by Anonymous Monk on Jul 15, 2014 at 10:04 UTC | |
|
Re: exit EXPR?
by Anonymous Monk on Jul 15, 2014 at 11:31 UTC |