Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Tkx after coderef problem

by Anonymous Monk
on Jun 02, 2018 at 11:58 UTC ( #1215731=note: print w/replies, xml ) Need Help??


in reply to Tkx after coderef problem

What do you think amperstand operator does ? You're to call subs that dont exist

Replies are listed 'Best First'.
Re^2: Tkx after coderef problem
by huck (Parson) on Jun 02, 2018 at 15:08 UTC

    Im not sure id call my use of ampersand an operator here. If i have the following

    my $code=sub{print "hi\n";}; &{$code};
    the &{} part references the code section of its contents and calls it, much like if i have
    my $var='hi'; my $ref=\$var; ${$ref}='there'; print "$var\n";
    the ${}part references the scalar section of its contents allowing me to set it with the assign statement.

    as for subs not existing, remember that for at least 1 and up to 5 times the call succeeded and the sub/coderef did exist, and at the end of MainLoop the sub/coderef still exists.

    To show that the coderef still exists and is valid if i changed the "debug" statment at the end to

    if ( $tkxfsr->{after}{$afterid}{sub}) { print 'sub:'.$tkxfsr->{after}{$afterid}{sub}."\n"; &{$tkxfsr->{after}{$afterid}{sub}}(); &{$tkxfsr->{after}{$afterid}{sub}}; }
    on ubuntu it still fails as it did before but now it prints out the next two items in the queue after printing 'sub:'.....

    Edit:add output

    encapulated sub=0 SCMD 1527954135_123_c1 hi LIST 1527954135_123_c1 hi 1---------- LIST 1527954135_123_c1 hi 2---------- LIST 1527954135_123_c1 hi 3---------- sub:CODE(0x9cdda24) LIST 1527954135_123_c1 hi 4---------- LIST 1527954135_123_c1 hi 5----------

      which sub is rAising invalid command? What command where? What is undefinex at time of sub call?

      The word is operator. If it's not an operator what is it a puppy?

        The word is operator. If it's not an operator what is it a puppy?

        It is not a puppy, it is a "dereferencing symbol"

        https://perldoc.perl.org/perlref.html
        "Because of being able to omit the curlies for the simple case of $$x , people often make the mistake of viewing the dereferencing symbols as proper operators"

        "which sub is rAising invalid command?" It is the Tkx::after command that is raising invalid command when its time has arrived to actually call its argument.

        "What command where?"The command is the one created by $tkxfsr->{after}{$afterid}{sub}=sub{ ...}; since the code address match.

        "What is undefinex at time of sub call? " Nothing is actually undefined at the time of the call, but for some reason the execution part of Tkx:after thinks it is.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-11-20 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (96 votes). Check out past polls.

    Notices?