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

Re: Dynamic Variable Names?

by erikharrison (Deacon)
on Jul 23, 2002 at 15:35 UTC ( #184453=note: print w/ replies, xml ) Need Help??


in reply to Dynamic Variable Names?

You can create variables dynamically, true. But that's not actually what you need here. When ever you have a series of scalars with trailing integers, use an array, and then you can access the array elements in your for loop. Also, using foreach is more idiomatic (which is a fancy word for "better written")

@foo = ('foo0', 'foo1', 'foo2', 'foo3'); foreach $member (@foo) { push @fee, $member; }
Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


Comment on Re: Dynamic Variable Names?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2015-07-06 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls