[Israel.pm] local not local?

Jason Elbaum jason.elbaum at gmail.com
Thu Dec 7 10:22:57 PST 2006


> I made a sample program, and the problem didn't show. Any idea?

I can guess: local temporarily overrides the value of a global
variable. You're trying to apply local to an identifier in a
non-global namespace.

Jason


> (I solved the problem by extending _color_role_to_index too, and made a
> switch. But that's not evil. :-) )
>
> Shmuel.
>
> ------ Start sample
> sub one { return "one" }
> sub two { return "two" }
> sub answer {
>     print "The answer is: ", one(), "\n";
> }
>
> answer();
> {
> #    local *one = \&two;
>     local *one = sub {return "three"};
>     answer();
> }
> answer();
> ------ End
>
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>



More information about the Perl mailing list