
FishMonger
Veteran
/ Moderator
Jun 13, 2012, 8:07 AM
Post #10 of 11
(4360 views)
|
Re: [ckramer] What kind of pattern match do I use ?
[In reply to]
|
Can't Post
|
|
$a and $b are special builtin global vars that are used in sort routines and it would be best to not use them outside of the sort routine. Also, you should not have multiple statements on a single line. You need to escape the [ ] brackets, which is done by using \Q
my $str1 = "slash_wideiscan"; my $str2 = "_mnn3h_reg[0]"; my @array1 = qw (slash_wideiscanps_mnn3h_reg[0] slash_wideiscanptlr_mnn3h_reg[0] slash_wideiscanps_mnn0h_reg); for my $element (@array1) { if ($element =~ /$str1.+?\Q$str2\E/) { print "YES : $element\n"; } else { print "NO : $element\n"; } }
(This post was edited by FishMonger on Jun 13, 2012, 8:08 AM)
|