Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: use strict

by dragonchild (Archbishop)
on Jun 01, 2004 at 12:59 UTC ( #358018=note: print w/replies, xml ) Need Help??


in reply to use strict

What you are attempting to do is called a symbolic or soft reference. There are hundreds of posts on Perlmonks as to why this is almost always not what you want to do. Basically, unless you know why you shouldn't do it, you shouldn't do it.

While EdwardG provided you a solution based on aliasing, the proper solution you are looking for is a hash.

my @interests = ( "foo", "bar", "blah" ); my %interest_expanded; foreach (@interests) { $interest_expanded{$_} = "My interest is $_"; } foreach (keys %interest_expanded) { print $_, " => ", $interest_expanded{$_} , "\n"; }

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2023-03-27 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (65 votes). Check out past polls.

    Notices?