Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: backwards if and while looping

by periapt (Hermit)
on Oct 01, 2004 at 19:55 UTC ( [id://395730]=note: print w/replies, xml ) Need Help??


in reply to backwards if and while looping

The line
while ($a < $b) if not $error { $a++; }
is more clearly interpreted by perl to be  while ($a < $b) if not $error{ $a++; }. Perl thinks $error{ $a++ } is a hash reference to %error. A construct that would DWYM would be (parenthesis not strictly necessary)
(!$error) && ($a++ while ($a < $b))

PJ
use strict; use warnings; use diagnostics; (if needed)

Replies are listed 'Best First'.
Re^2: backwards if and while looping
by jcpunk (Friar) on Oct 01, 2004 at 20:20 UTC
    My dumbed down example seems to not be as excellent as I initially thought.....
    (!$error) && (print "$data" while ($data = <input>))
    is erroring out on me with the print... Is this a fatal flaw in my plan?

    jcpunk
    all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)
      $error or print $data while $data = <input>;

      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found