develooper Front page | perl.perl5.porters | Postings from April 2010

[perl #6813] tie() magic upsets stack (can't last() outside of block)

Thread Previous
From:
Alexandr Ciornii via RT
Date:
April 29, 2010 04:21
Subject:
[perl #6813] tie() magic upsets stack (can't last() outside of block)
Message ID:
rt-3.6.HEAD-27388-1272540091-1820.6813-14-0@perl.org
Still dies on 5.12.0.

http://rt.perl.org/rt3/Ticket/Display.html?id=6813

On Thu Apr 12 08:27:58 2001, RT_System wrote:
> >jpinyan@sushi.riskgrades.com wrote:
> >> 
> >[snip]
> >> sub STORE {
> >>   my ($self, $val) = @_;
> >>   local $_ = $self->{VAL} = $val;
> >>   $self->{CODE}->() ? $_ : last;   # <-- bad news
> >> }
> >[snip]
> >> When I run this code, I'm told I can't call last() from outside a loop
> >> block.
> >
> >That is only a warning.  Your code should still work as you expect.  One
> >other way to suppress the warning (not mentioned on fwp) would be to put
> 
> No, that is not a warning.  A warning is when you use last() to get out of
> a loop while in a subroutine.  This message is a fatal error:
> 
>   Can't "last" outside a loop block at ensure line 23.
> 
> It occurs because when Perl gets to STORE via tie() magic, it
> "forgets" itself.


-- 
Alexandr Ciornii, http://chorny.net


Thread Previous


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