in reply to Using a variable to define a variable

Possible? Yes. Advisable? No. Perl has arrays which would be ideal for this instead. eg.

my $ecounter = 0; my @e = (); my @file_line_contents = split (/\|/,$_); while ($ecounter < 45) { # Note brackets, not quotation marks! $e[$ecounter] = length($file_line_contents[$ecounter]); $ecounter++; }

But there are probably more perlish ways to achieve the same result and which would be more fault-tolerant into the bargain.

Replies are listed 'Best First'.
Re^2: Using a variable to define a variable
by AnomalousMonk (Archbishop) on May 08, 2015 at 15:56 UTC