On Mon, Sep 24, 2007 at 10:05:13AM +0200, demerphq wrote:
> On 9/23/07, Dave Mitchell <davem iabyn.com> wrote:
> > On Sat, Sep 22, 2007 at 08:05:59AM -0700, Chris
Dolan wrote:
> > > These should output the same value, but
instead the first one emits
> > > "f" and the second one undef.
> > >
> > > my $qr = qr/(f)/;
> > > print "#f" =~ m/[#](f)/x;
> > > print "#f" =~ m/[#]$qr/x;
> > >
> > > This is more revealing:
> > >
> > > print qr/[#]$qr/x;
> > >
> > > yields:
> > >
> > > (?x-ism:[#]$qr
> > > )
> > >
> > > So, it appears that [#] is disabling
interpolation for variables that
> > > follow, but then still treating the content
as regexp. Clearly, it's
> > > not *just* treating it as a comment, or the
remaining qr/[/ would be
> > > a syntax error.
> >
> > Hmm, looks like the tokenizer isn't smart enough
to know to ignore #'s
> > when within a character class. S_scan_const()
needs to be made even more
> > scary than it already is. Probably a post 5.10.0
job.
>
> It is not clear to me that this is a bug actually. The
documentation
> states that # must be escaped in an /x pattern afair.
But it also says that # isn't special when in a character
class:
$ ./perl -Dr -e'/[#]a
b/x'
Compiling REx "[#]a%nb"
rarest char # at 0
Final program:
1: EXACT <#ab> (5)
5: END (0)
$ perl -le'print "ok" if "#" =~
/[#]/x'
ok
$
--
Britain, Britain, Britain! Discovered by Sir Henry Britain
in
sixteen-oh-ten. Sold to Germany a year later for a pfennig
and the promise
of a kiss. Destroyed in eighteen thirty-forty two, and
rebuilt a week
later by a man. This we know. Hello. But what of the people
of Britain?
Who they? What do? And why? -- "Little Britain"
|