jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:
C:\>perl -c -e "use strict; {}; no strict \"refs\";"
Output:
-e syntax OK
Now delete the semicolon after the block:
C:\>perl -c -e "use strict; {} no strict \"refs\";"
Output:
String found where operator expected at -e line 1, near "no strict "re +fs"" (Do you need to predeclare no?) "no" not allowed in expression at -e line 1, near "} " syntax error at -e line 1, near "} no strict " -e had compilation errors.
I see what's happening, but was startled when this happened inside a script. Is an empty block indeed not a block, but a statement requiring a semicolon terminator?
Jim Keenan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is an empty block not a block?
by Roy Johnson (Monsignor) on Nov 18, 2005 at 22:03 UTC | |
by diotalevi (Canon) on Nov 18, 2005 at 22:29 UTC | |
|
Re: Is an empty block not a block?
by GrandFather (Saint) on Nov 18, 2005 at 21:49 UTC | |
by chas (Priest) on Nov 18, 2005 at 22:18 UTC | |
by eric256 (Parson) on Nov 18, 2005 at 23:00 UTC | |
|
Re: Is an empty block not a block?
by Aristotle (Chancellor) on Nov 19, 2005 at 04:32 UTC |