Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Mixing tied variables with goto label

by dave_the_m (Parson)
on Nov 16, 2005 at 00:27 UTC ( #508852=note: print w/ replies, xml ) Need Help??


in reply to Mixing tied variables with goto label

goto only searches the immediate call stack for labels, ie where perl code has called a function. Functions that are called indirectly, like signal handlers, tie handlers, sort functions etc don't get searched. I don't know whether this is documented.

Dave.


Comment on Re: Mixing tied variables with goto label
Re^2: Mixing tied variables with goto label
by Limbic~Region (Chancellor) on Nov 16, 2005 at 00:50 UTC
    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

Re^2: Mixing tied variables with goto label
by Steve_p (Priest) on Nov 16, 2005 at 21:07 UTC

    Where do you think would be a good place to document this? perlfunc doesn't seem like the right place, so perlsyn maybe?

      It should go in perlfunc, in the section on goto

      Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://508852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-08-01 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls