[Pdx-pm] Not a syntax error?
Michael G Schwern
schwern at pobox.com
Mon May 2 16:16:13 PDT 2005
On Mon, May 02, 2005 at 03:57:08PM -0700, Steve Bonds wrote:
> #!/usr/local/bin/perl -w
> print "This is a line without a semicolon\n".
> exit 1;
> It almost seems like the print line uses string concatenation to
> absorb the exit line-- but it doesn't. The exit line is executed
> properly and the above perl terminates with status 1, however the
> output from the print statement is never seen.
> This didn't generate a warning using perl 5.8.0. Should it have?
Nope. Think of it like this.
my $return_from_exit = exit 1;
print "This is a line without a semicolon\n". $return_from_exit;
The arguments to a function are evaluated *before* the function is
executed. Thus exit(1) happens before print but since exit ends the
program the print never happens.
More information about the Pdx-pm-list