in reply to Global vs. local?
foreach my $j (0..$i-1) { $SUB = $j."Textfield_MaxText"; ... *$SUB = sub { variableMaxText(0); };
This will create a typeglob with an illegal subroutine name - sub names may not start with a digit. You can do that, but the sub can not be called directly by name:
$SUB = "1Foo"; *$SUB = sub {print "$SUB!\n"}; 1Foo(); Bareword found where operator expected at -e line 3, near "1Foo" (Missing operator before Foo?)
To call that weird sub, you'd have to do
$SUB = "1Foo"; *$SUB = sub {print "$SUB!\n"}; &{"1Foo"}; __END__ 1Foo!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Global vs. local?
by lodin (Hermit) on May 28, 2009 at 13:53 UTC | |
by shmem (Chancellor) on May 28, 2009 at 18:18 UTC | |
by lodin (Hermit) on May 29, 2009 at 13:59 UTC | |
by shmem (Chancellor) on May 29, 2009 at 17:44 UTC | |
by Corion (Patriarch) on May 29, 2009 at 17:52 UTC | |
|