Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Why is this script giving syntax errors?

by Old_Gray_Bear (Bishop)
on Nov 02, 2013 at 21:00 UTC ( [id://1060978]=note: print w/replies, xml ) Need Help??


in reply to Re: Why is this script giving syntax errors?
in thread Why is this script giving syntax errors?

kenosis said:
Since close FILE is the last statement in the second script, the ; is optional.
The semi-colon is only option if it's omitted from the last line of your code. As the OP pointed out, the last line of the code doesn't stay that way for very long; there is always one more subroutine to be added.

I view the 'optional' semi-colon the same way I view the 'optional' comma on the last item of a list. I just know that I'll want to add something else later, and since the Perl compiler is forgiving, I just add it automatically.

Nota Bene: Just because I know that some particular piece of punctuation is optional (in the sense that the Compiler does the right thing if it is present or absent) doesn't automatically mean that I will remember when I am debugging a problem at O'Dark-Hundred with the entire site down. Don't leave land-mines lying around for the next person to stumble over two years later, it may be you....

Update =====
Added the quote from kenosis

----
I Go Back to Sleep, Now.

OGB

  • Comment on Re^2: Why is this script giving syntax errors?

Replies are listed 'Best First'.
Re^3: Why is this script giving syntax errors?
by Kenosis (Priest) on Nov 02, 2013 at 21:43 UTC

    The semi-colon is only option if it's omitted from the last line of your code.

    Perhaps I'm misunderstanding you here, but when I mentioned "statement," I (implicitly) meant a line containing a set of executable commands, since a semi-colon isn't required on any one of the last four lines of the following script:

    use strict; use warnings; print "Hello, world.\n"; # # # #

    My use of the term "statement" may not have been the best, in this context.

    Your Nota Bene bears an especially crucial message and I appreciate you adding it. Thank you, and the message is well noted.

Re^3: Why is this script giving syntax errors?
by Tux (Canon) on Nov 03, 2013 at 11:59 UTC

    "The end of the script" is just part of the truth. It actually is "The end of a scope":

    $ perl -MO=Deparse -e'print $a' print $a; -e syntax OK $ perl -MO=Deparse -e'{print $a}' { print $a; } -e syntax OK $ perl -MO=Deparse -e'{print $a}print $a' { print $a; } print $a; -e syntax OK

    Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1060978]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found