Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: How's your Perl?

by xmath (Hermit)
on Oct 27, 2003 at 10:31 UTC ( #302368=note: print w/replies, xml ) Need Help??


in reply to Re: How's your Perl?
in thread How's your Perl?

1. yes

2. no and yes (perl treats while1 as one identifier)

3a. yes

8a. yes, cool, unexpected solution :-)   our official version uses a much much more obscure trick.. funny we never saw this one
Try this instead: eval(q[$$foo]) ne eval(q["$$foo"])
•Update: actually, no, the original was fine too.. even though $$foo and $$foo + 0 print differently, they don't compare numerically unequal, which is what the exercise was

11. doesn't appear to work for me..

% perl -e 'sub STDOUT{\*STDOUT} <STDOUT> eq <+STDOUT> or die' Died at -e line 1.

12. yes, but why? :-)

•Update: fixed the "try this".. initially said "!=" instead of "ne"

Replies are listed 'Best First'.
Re: Re: Re: How's your Perl?
by BrowserUk (Pope) on Oct 28, 2003 at 02:30 UTC
    12. yes, but why? :-)

    I missed this before.

    For the same reason that these give a similar error

    D:\TEMP>perl -e"sub f{'fred'} goto +f" Can't find label SCALAR(0x15d7c1c) at -e line 1. D:\TEMP>perl -e"sub f{'fred'} goto(f)" Can't find label SCALAR(0x15d7c1c) at -e line 1. D:\TEMP>perl -e"sub f{'fred'} goto f->()" Can't find label SCALAR(0x15d7c1c) at -e line 1.

    But these do not ;^)

    D:\TEMP>perl -e"sub f{'fred'} goto ~~f" Can't find label fred at -e line 1. D:\TEMP>perl -e"sub f{'fred'} goto ''.f" Can't find label fred at -e line 1. D:\TEMP>perl -e"sub f{'fred'} goto scalar f" Can't find label fred at -e line 1. D:\TEMP>perl -e"sub f{'fred'} goto ${\f}" Can't find label fred at -e line 1.

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!

      For the same reason that these give a similar error

      Yes but why ?   :-)

      Juerd found this one originally, and while it was obviously a parser bug, it initially puzzled us how it managed to produce that reference. (Because it takes a walk through the perl source code to truly understand the issue, I made it a bonus exercise instead of a regular one)

        I will finally admit :) that whilst I think I know the When and the Where, I haven't a clue as to the Why!

        P:\test>perl -MO=Concise -e"sub f{}; goto +f" b <@> leave[t1] vKP/REFC ->(end) 3 <0> enter ->4 4 <;> nextstate(main 2 -e:1) v ->5 a <1> goto vKS/1 ->b 9 <1> refgen sK/1 ->a ## <<<HERE. - <1> ex-list lKRM ->9 5 <0> pushmark sRM ->6 8 <1> entersub[t2] lKRMS/NO(),TARG,INARGS,1 ->9 - <1> ex-list lK ->8 6 <0> pushmark s ->7 - <1> ex-rv2cv sK/129 ->- 7 <#> gv s ->8 -e syntax OK

        Even wading through pp_goto, I couldn't quite work out why it only happens if the function is called in a list context, or indeed why it takes a reference at all. Gut feel tells me its something to do with the fact that the code tries for the goto SUB; variation prior to the goto -LABEL and goto -EXPR variations, and that something is being stacked and not cleaned up, but that's about as far as I got before my brain went into overload.

        One good thing came out of it. I now have a much better appreciation of why goto \&func is so gaddamn slow. All that chundering around unwinding stack frames, validating the target isn't a prohibited one etc. I never imagined. I'd always invisioned a simple longjump().


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        Hooray!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://302368]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-06-20 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (116 votes). Check out past polls.

    Notices?