Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] More fun with Perl



Quoth Josh Glover (Fri 2003-01-31 03:41:00PM -0500):
>
> Perl hackers, I need your help!

[...]

> My question is this: when $chunk == "\$foo" and $str =~ /\$foo/ is true, why
> is $str =~ /$chunk/ not true?
> 
> My theory is that Perl is interpreting /$chunk/ as end-of-line, followed by
> literal "chunk". This is certainly not what I want. And Perl is behaving the
> way that I expect (i.e. evaluating $chunk first and trying to match its value
> literally) in other places in my code.

My theory was wrong. It turns out that $chunk needed to actually say "\$foo"
instead of "$foo". So I had to play with $chunk:

$chunk =~ s/\$/\\\$/;

Now things work the way I wanted them to. And I am reminded how much I hate
Perl! :-P


--Josh


-- 
Josh Glover <jmglov@example.com>

Associate Systems Administrator
INCOGEN, Inc.
http://www.incogen.com/

GPG keyID 0x62386967 (7479 1A7A 46E6 041D 67AE  2546 A867 DBB1 6238 6967)
gpg --keyserver pgp.mit.edu --recv-keys 62386967

Attachment: pgp00003.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links