in reply to Help with perl syntax
For example,
can be rewritten like this:unless (/^#!/) {next READ if (/^\s*#/)};
Notice how there's really two logical operations going on, completely separate from one another. First, the "unless", with its code-block, and then (within the "unless" code block) an "if" statement with its own code-block. Makes perfect sense, and the Perl interpreter has no problems.unless (/^#!/) { if (/^\s*#/) { next READ; } }
However, the next example:
would be rewritten as:if (/^\s*#/) { next READ } unless (/^#!/);
which doesn't work at all. Where's the code-block for the "unless" statement? Perl doesn't see one, and so throws up its hands because it doesn't know what to do.if (/^\s*#/) { next READ } unless (/^#!/);
If you confuse yourself with the reverse notation, just try to rewrite it in the "proper" way and you'll see very clearly what will and won't work.
Gary Blackburn
Trained Killer
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Help with perl syntax
by merlyn (Sage) on Oct 29, 2000 at 05:42 UTC |