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} ); ... }
_________
broquaint
In reply to Re: space saving wanted!
by broquaint
in thread space saving wanted!
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |