Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Perl Monk, Perl Meditation
 
PerlMonks  

Use B::Deparse to see why

by htoug (Deacon)
on Sep 23, 2004 at 14:05 UTC ( #393203=note: print w/ replies, xml ) Need Help??


in reply to Surprising whitespace behavior

If you try perl -MO=Deparse you will see that the perl compiler interprets the print statement as you surmised:

my(@a) = ('a', 'b', 'c', 'def'); my $s = 'foo'; print "s=$s, a=\@ a\n"; - syntax OK
Why there is a difference between the interpretation of $ followed by whitespace and @ followed by whitespace probably lies in the fact that @-interpolation is a quite new invention (5.6 AFAICR).

-MO=Deparse is very handy for finding out why a coinstruct does what it does (and for deobfuscation).


Comment on Use B::Deparse to see why
Select or Download Code
Re: Use B::Deparse to see why
by dragonchild (Archbishop) on Sep 23, 2004 at 14:11 UTC
    5.005_3 had @-interpolation. I'm not sure about older Perls.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

•Re: Use B::Deparse to see why
by merlyn (Sage) on Sep 23, 2004 at 14:13 UTC
    probably lies in the fact that @-interpolation is a quite new invention (5.6 AFAICR).
    Oh, you young'uns. {grin}

    @-interpolation in a string dates back to Perl version 5.000. It's the reason that you get the fatal error when you have something like "merlyn@stonehenge.com".

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      @-interpolation in a string dates back to Perl version 5.000.

      Oh, you young'uns. (:

      It dates back way before that. I've personally used @-interpolation in strings in Perl v3.

      > perl4 -e "print qq<(tye@ARGV)\n>" this that (tyethis that) > perl4 -e "print qq<(tye@foo)\n>" this that (tye@foo)

      What changed with Perl5 was that the DWIM of optional interpolation was removed.

      The only reason the second example needs to be fatal in Perl5 is so that the change in behavior was not a "silent change".

      I suspect you know all of this, but your node was at least misleading so I felt clarification was in order.

      - tye        

        Oddly enough, that's what I was trying to think, but it was too early in the morning for me to remember that. I kept thinking "wasn't @foo interpolated as far back as perl 2?" But then I couldn't remember why the error was added in perl5.

        Thanks for the clarification. I'm getting too old for this. {grin}

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-04-18 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (465 votes), past polls