$b = 5; { local *b; *b = *a; $b = 20; } print $a; # 20 print $b; # 5
Es un error intentar hacer un typeglob de una variable privada (my
)
de tipo typeglob:
$ cat mytypeglob.pl #!/usr/bin/perl -w use strict; my *a; my $b; *a = *b; $ ./mytypeglob.pl syntax error at ./mytypeglob.pl line 4, near "my *a" Execution of ./mytypeglob.pl aborted due to compilation errors.