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

Re: for loop ?

by philipbailey (Chaplain)
on Aug 10, 2011 at 19:43 UTC ( #919725=note: print w/ replies, xml ) Need Help??


in reply to for loop ?

Of course, for is indeed a looping construct, but in this case the for loops each have only one iteration. The programmer is using the "for" to set the default variable $_ to the value of $os or $hardware in each case, then performing a regular expression match (/.../), implicitly on $_, against various values. Older Perls (5.8 and prior) do not have a switch statement (well, given/when statement), so various other approaches have been used in the past to emulate one. I would probably not use this particular approach myself, but it seems to work well enough.


Comment on Re: for loop ?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2016-02-12 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (395 votes), past polls