
phil_t
Novice
Feb 14, 2007, 1:04 PM
Post #8 of 13
(708 views)
|
My apologies...I'm not communicating very well in this thread. Thank you, Kevin, for your help. Please bear with me a little more, though. Let me start over. If I want this to happen: xxxgoodxxx (match) xxxgoodbadxxx (not match) xxxgoodxxxbad (not match) xxx (not match) What ONE condition can I create (i.e. what can I assign $testval to be) that will match when it finds 'good', but negate the match if it finds 'bad' afterward? Assuming the code is in the form: $testval = qr/good.*?bad/; # let's change only this line foreach my $teststr ('xxxgoodxxx' , 'xxxgoodbadxxx' , 'xxxgoodxxxbad') { if ($teststr =~ /$testval/) { print "$teststr: has good but not bad\n"; } else { print "$teststr: does not have good or has bad\n"; } } I'd be curious to know if we can write the condition such that xxxbadxxxgood (not match) but I don't think I need the condition to be that smart quite yet. Also, I'm a little confused what you did with $testval. I don't quite understand what qr/.../ is doing. Can you explain? Thanks again for your help. Hope I'm making myself clear in this post.
|