Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Derive a variable name from a variable?

by Lennotoecom (Pilgrim)
on Dec 17, 2015 at 06:47 UTC ( #1150588=note: print w/replies, xml ) Need Help??


in reply to Derive a variable name from a variable?

there is another way,
but that is a path to the dark side of the force
@names = qw/adam jake john betty/; @adambooks = qw/ad_1 ad_2/; @jakebooks = qw/ja_1 ja_2/; for $n (@names){ print "$n:\n"; print "\t@{$_}\n" for $n."books"; }

there might be some jedi,
who'd tell you that it's wrong
they just want you to obey their will

Replies are listed 'Best First'.
Re^2: Derive a variable name from a variable?
by LanX (Sage) on Dec 21, 2015 at 15:51 UTC
    This is only half the answer because using strict is a standard nowadays.

    There might be cases where this is needed, but please apply no strict "refs" in a restricted block around it and use strict; in file scope.

    see for instance no strict refs for blocks?

    > there might be some jedi,

    > who'd tell you that it's wrong

    > they just want you to obey their will

    Perl has no taboos, just best practices.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re^2: Derive a variable name from a variable?
by mavericknik (Sexton) on Dec 18, 2015 at 21:25 UTC
    Haha I would've been seduced by the dark side if it weren't for the wisdom of the monks here!
      ^_^

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2023-01-28 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?