http://www.perlmonks.org?node_id=508858


in reply to Re: Mixing tied variables with goto label
in thread Mixing tied variables with goto label

dave_the_m,
I couldn't find it documented anywhere. So it is how the function is called that is causing the problem. I can still produce a fair amount of misdirection. I am not sure I have the time or energy to actually make the obfu, but I would be happy and impressed if someone did. Like most magic and misdirection, the most important part is the setup.

You will need to hide the tie, sub TIESCALAR, and friends. This should be possible using evil eval. The FETCH needs to be special too. Instead of using an internal goto to produce the magic, it will return the current value in the STORE the first time, but the second time it will return a different label.

my $label; # magic setup happens here $label = 'START'; print "$label\n"; # prints START goto $label; exit; START: print "Hello, world\n"; END: print "Goodbye, cruel world\n";
When it is run, the output will be unexpected:
START Goodbye, cruel world
In any case, if you happen to find some documentation explaining this behavior I would appreciate it.

Cheers - L~R