in reply to Declaring variables recursively
I would like to declare variables recursively, this way I could save lots of time in associating data of arrays hashes etc. What I would like to to is the following: foreach $name (@array){ ${$name}=X } is it possible con perl?, because its posible with linux shell. Thanks
takes only a few more keystrokes... (well, actually less, but that's only because I used for as a statement modifier.)$hash{$_} = X for @array;
In particular there are tons of mails/posts/nodes/articles explaining why it is generally recommended not to use symrefs, which is also the reson why they're ruled out by use strict; (hey, you're using it, aren't you?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Declaring variables recursively
by sciarnold (Initiate) on Feb 25, 2005 at 16:05 UTC |