in reply to for loop help

Well, you could certainly do what you want to do using eval, but fundamentally it looks like you have the wrong data structure for the job.

Rather than having a bunch of scalars you might consider using an array, or a hash, or most likely a hash of arrays. Since I'm not certain of the relative significance of the scalar letters (a,b,c) and the apparent index numbers (1,2,3) it is difficult to make a specific recommendation.

I'm sure a fast-coder will follow-up with some magical sample code shortly.

Replies are listed 'Best First'.
Re^2: for loop help
by codeacrobat (Chaplain) on May 16, 2006 at 12:45 UTC
    don't do that ;-)
    use strict; my $a1 = 0; my $a2 = 1; my $a3 = 4; my $b1 = 8; my $b2 = 2; my $b3 = 9; my $c1 = 1; my $c2 = 4; my $c3 = 7; for (my $i=1; $i<=3; $i++) { print eval "\${a$i} . \${c$i}. \${c$i}" }