[Pdx-pm] Not a syntax error?

Ovid publiustemp-pdxpm at yahoo.com
Mon May 2 16:14:01 PDT 2005

--- Steve Bonds <9nn24e402 at sneakemail.com> wrote:
> Perl folks:

> -----
> #!/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?

I would be surprised if it could find anything wrong with that as the
syntax is quite valid.  print() is only going to print the value of the
expression passed to it, but in order for perl to know what that value
is, it must first evaluate the Perl.  Thus, the exit is evaluated and
the program exits on the spot.  It's like calling exit() in the middle
of a subroutine; perl wouldn't have any reason to delay the exit until
subroutine completion.


If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

More information about the Pdx-pm-list mailing list