SPUG: regex problems...

Sean seanow0 at email.msn.com
Fri Oct 1 13:11:25 CDT 1999

I don't pretent to be an expert at Perl, so hopefully this isn't a silly question everyone but me knows:

I'm doing some search & replace functions, and I've assigned some big strings of HTML to variables, and I've got a question about the s/// function:

If I say:

$snip='<a href="http://blah.foo.com/index.htm" class="style"';
$code =~ s/$snip/[replacement/gsi;

$code =~ s/<a href="http://blah.foo.com/index.htm" class="style"/[replacement/gsi;

I know example 2 is wrong and I need to escape a few characters, but why won't example 1 work?  If I change $snip to ="blah" then the expression will return true, but the full html variable always returns false, even though I can see that exact line in my code.  Can anyone tell me what I'm doing wrong?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/19991001/572a5682/attachment.htm

More information about the spug-list mailing list