develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991115.012] Localization and goto()

From:
Ilya Zakharevich
Date:
November 16, 1999 00:14
Subject:
Re: [ID 19991115.012] Localization and goto()
Message ID:
199911160814.DAA19359@monk.mps.ohio-state.edu
Sam Tregar writes:
> 
> > $a = 5;
> > sub a { print $a }
> > sub b {local $b = 9; goto &a}
> > b;
> > 
> > This prints 5.  "Should" not it print 9 instead?
> 
> What?  No!
> 
> Maybe if you said "local $a = 9" it would!

Thanks for this correction.  My test script was busted, but my
conclusion is not:

$a = 5;
sub a { print $a }
sub b {local $a = 9; goto &a}
b;

This still prints 5... :-(

Ilya



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About