Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Perl6::Rules oddity?

by supergiantrobot (Acolyte)
on May 03, 2004 at 16:37 UTC ( #350076=perlquestion: print w/ replies, xml ) Need Help??
supergiantrobot has asked for the wisdom of the Perl Monks concerning the following question:

P6R is fun, but a little maddening, too. I see that I am going to have to learn Perl 6 more! Anyway, I am stumped why $0 doesn't contain three hash keys in the code below. The input looks like this:
hEAD: one DeCK: two By: three four I<five six> BiO: seven
Shouldn't $0 have hash keys foo and deck?
use strict; use Perl6::Rules -debug; rule head :i { HEAD <COLON> } rule deck :i { DECK <COLON> } rule byline :i { BY <COLON> } rule bio :i { BIO <COLON> } rule body :w { <para> [<blankline> <para>]* } rule para :w { <line>+ } rule figure :i { } rule line { <word>+? \v } rule word { <italics> | <[\S+]>? } rule italics :w { I <LANGLE> ([<word>|\v]+) <RANGLE> } rule blankline { ^^$$ } rule COLON { \: } "abcd" =~ m/a $?foo:=(..) d/; print "yes" if ($0->{foo} eq "bc"); $0->dump(); # # get all input my @line = <>; my $line = join('', @line); if ($line =~ m:words/ <head> $?foo:=(<line>) <deck> $?deck:=(<line>) [<byline> $?by:=(<line>)]? /) { $0->dump(); }

Comment on Perl6::Rules oddity?
Select or Download Code
Re: Perl6::Rules oddity?
by TheDamian (Priest) on May 03, 2004 at 22:22 UTC
    Definitely a bug. I'm working on a fix (in my CFT).

    Damian

      Thanks for the reply, DC. Do I get some camel poo as a token of my obfuscation? :-)
        Sorry, we reserve camel dung for our Special Friends who ask questions that are already answered in TFM. ;-)
Re: Perl6::Rules oddity?
by hossman (Prior) on May 04, 2004 at 06:32 UTC

    Ya know, as someone still running 5.6, I've never really taken a good look at Perl6::Rules. It never occured to me that the Damain's perl5 implementation would acctually set $0.

    That must make for some interesting "ps" output while doing lots of parsing.

      While $0 is used to neat effect its associated perl5 MAGIC is not used, and I quoth from the source
      # Turn off special $0 magic *0 = \ my $zero;
      After that $0 will loose it's magical behaviour e.g
      shell> perl -MDevel::Peek - Dump $0; *0 = \ my $zero; Dump $0; ^D SV = PVMG(0x99900b0) at 0x999410c REFCNT = 1 FLAGS = (GMG,SMG,pPOK) IV = 0 NV = 0 PV = 0x99950e8 "-"\0 CUR = 1 LEN = 2 MAGIC = 0x99950f8 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x9994100 MG_LEN = 1 MG_PTR = 0x9995118 "0" SV = NULL(0x0) at 0x9997828 REFCNT = 2 FLAGS = (PADBUSY,PADMY)
      Although leaving $0 scrubbing out could certainly lead to some interesting debugging facilities in conjunction with top ;)
      HTH

      _________
      broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://350076]
Approved by matija
Front-paged by Tomte
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2015-07-06 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (84 votes), past polls