Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Loop Control : REDO

by suaveant (Parson)
on May 02, 2001 at 18:35 UTC ( [id://77334]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Loop Control : REDO
in thread Loop Control : REDO

yours is good, but why chomp? no need with that regexp...
print "** Random 4 Lotto Numbers **\n"; print "** Type any four digits (0 to 9) **\n"; for ($i=1; $i <= 4; $i++) { print "Choice $i: "; redo if ($digit[$i] = <STDIN>) !~ /^\d$/; } print "Your choices :@digit \n";
since the $ works fine with \n there
                - Ant

Replies are listed 'Best First'.
Re: Re: Re: Re: Loop Control : REDO
by iakobski (Pilgrim) on May 02, 2001 at 18:45 UTC
    You are quite right that $ in regex will match at the end of the line, but you still need the chomp, otherwise the newlines get into the array.

    iakobski

      Ack... yup... my bad... :)
                      - Ant

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found