in reply to space saving wanted!
I wondered if there was a neat way of foreaching through a list of varibles that are names sequentiallyThere is, but don't do it. That may sound harsh, but use of symbolic variables is almost categorically a bad thing as a certain Mr. Dominus illustrates in Why it's stupid to `use a variable as a variable name' (with follow up articles here and here).
The alternatives are either creating an array instead of dynamically generating variables, or just use a hash e.g
See. perldata for info on array slicing and the map docs for info on map.## using an array my @calcs = some_function(); for(@calcs[0 .. 3]) { ... } ## using a hash for my $k (map "calc$_", 1 .. 4) { do_stuff( $calc{$k} ); ... }
HTH
_________
broquaint
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: space saving wanted!
by Jenda (Abbot) on Apr 23, 2003 at 11:11 UTC |
In Section
Seekers of Perl Wisdom