- To: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [SLUG] Stupid Regex questions..
- From: Scott Howard <scott@xxxxxxxxxx>
- Date: Wed Jul 12 11:35:02 2000
- Cc: slug@xxxxxxxxxxx
On Tue, Jul 11, 2000 at 11:34:59PM +0000, Herbert Xu wrote:
> > Except that in Perl the $ord would normally be interpreted as the variable
> > $ord, and thus the $ needs to be quoted (or some other quoting would be
> > required).
>
> But in the scope of a regex, the first $ can not be interpreted as the prefix
> of a variable. The second may be but only if you use s///e.
Umm.. Perl disagrees with you :)
isd70{showard}5: cat q.pl
#!/usr/bin/perl
$aa="bb";
while(<>) {
s/$aa/xx/g;
print;
}
isd70{showard}6: ./q.pl
$aa <- Enter this
$aa <- It didn't match
bb <- Enter this
xx <- And it did!
isd70{showard}7:
It's matching on the contents of the variable, not "$aa".
Scott.