On Aug 3, West, William M said:

>$ perl -e ' $entry = "willy"; (print "1") if (/$entry/) while ($_ = "will");
>print "0"'
>syntax error at -e line 1, near ") while"
>Execution of -e aborted due to compilation errors.

Check 'perldoc perlsyn'.  It explains that the "statement modifiers",
things like '... if CONDITION' and '... while CONDITION' are only allowed
after *simple* statements -- what they really should say is "expressions".

You're allowed to write

  print 1 if /willy/;

because 'print 1' is an expression.  You can't write

  print 1 if /willy/ while <FILE>;

because 'print 1 if /willy' is not an expression, it's a statement.

-- 
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to