[EMAIL PROTECTED] wrote:
>
> Hi.
>
> How can I isolate stuff inside a string so that two identical strings
> will match when they ought to? Sample code:
>
> $str1 = " <TD class=xd01>3.04 (build 14)</TD>";
> $str2 = "3.04 (build 14)";
>
> if ($str1 !~ /$str2/) {
> print "no match?\n";
> }
> else {
> print "match!\n";
> }
>
> The result this yields is "no match?", and not what I expect: "match!".
> I suspect the parentheses are responsible for this, so how can I rewrite
> the comparison to yield the result I need--and still work with other,
> more normal, strings?
use strict;
my $str1 = " <TD class=xd01>3.04 (build 14)</TD>";
my $str2 = '3.04 (build 14)';
if ($str1 =~ /\Q$str2\E/) {
print "match '$str2' in '$str1'\n";
} else {
print "no match '$str2' in '$str1'\n";
}
__END__
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs