in reply to Global vs. local?
switch ($j) {
Whoa! Don't.
This code suggests to me that you're using Switch, which is known to introduce random and weird errors into your scripts. The first step is to remove everything related to Switch.
After you've exorcised all usage of Switch from your script, your usage should basically work. Potentially, you need to declare another variable and store the index in it rather than the loop variable:
foreach my $j (0..$i-1) { my $idx = $j; # make a copy my $SUB = "${idx}Textfield_MaxText"; *$SUB = sub { variableMaxText( $idx ); };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Global vs. local?
by moritz (Cardinal) on May 28, 2009 at 09:32 UTC | |
by jpavel (Sexton) on May 28, 2009 at 09:40 UTC | |
|
Re^2: Global vs. local?
by jpavel (Sexton) on May 28, 2009 at 09:46 UTC | |
by ig (Vicar) on May 28, 2009 at 10:55 UTC | |
by jpavel (Sexton) on May 28, 2009 at 12:02 UTC | |
by Corion (Patriarch) on May 28, 2009 at 12:10 UTC | |
by ig (Vicar) on May 28, 2009 at 12:35 UTC |