Re: Is it a bug or is it just me?

[email protected] ((Randal L. Schwartz))
Newsgroups perl.recdescent
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "Ken" == Ken Lacrosse <[email protected]> writes:

Ken> The following fragment exhibits some odd (to me) behaviour in
Ken> that the @item array in the phrases rule does not return the
Ken> value for the conjunction subrule although the %item hash does
Ken> contain it.  My assumption is that grouping the subrules
Ken> conjunction and phrase has something to do with this but the
Ken> question is whether or not this is expected behaviour.  Then
Ken> again it could just be me messing up the $return values somehow.
Ken> :-)

Ken> Anyone?

Ken> Ken

Ken> phrases: phrase (conjunction phrase)(s?)
Ken>      {
Ken>           print "$item{conjunction}\n";
Ken>           print "phrases = " . Dumper(\@item);
Ken>           1;
Ken>      }

It's undefined in the docs what happens when you access $item{foo}
when "foo" is not an immediate subrule of the current rule.  I bet
you're getting burned by that.  So, in a word, don't do that!

If you want a name for the second part, invent a named subrule:

phrases: phrase more_stuff { print "$item{more_stuff}"; }
more_stuff: (conjunction phrase)(s?)
...


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.