Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: User defined function in while loop

by toolic (Bishop)
on Jun 19, 2015 at 18:43 UTC ( [id://1131172]=note: print w/replies, xml ) Need Help??


in reply to User defined function in while loop

Yes. This considers 1 as TRUE and 0 as FALSE:
use warnings; use strict; my $i = 0; while (foo($i)) { print "i = $i\n"; $i++; } sub foo { my $x = shift; return ($x < 5) ? 1 : 0; } __END__ i = 0 i = 1 i = 2 i = 3 i = 4

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-24 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found