swissknife has asked for the wisdom of the Perl Monks concerning the following question:
Hello
i am trying to match exact match using grep function. I have few values in an array which looks like below
print "@arr2"; output: mcs scr tsz unh print "@arr1"; output: spec.srn.1235 spec.mcs.1235
now i am following below operation but it always go to ELSE condition where i would expect for value "spec.mcs.1235" to come in IF condition
Could someone let me know what is wrong here? swissknifeforeach $strfile (@arr1) { @arr3 = split(/[.\n]/, $strfile); if (grep (/^@arr3[1]$/, @arr2)) { print "Entered in IF"; } else { print "Entered in ELSE"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl grep with regex
by choroba (Cardinal) on Jun 30, 2014 at 12:36 UTC | |
by swissknife (Sexton) on Jun 30, 2014 at 13:33 UTC | |
by choroba (Cardinal) on Jun 30, 2014 at 13:37 UTC | |
by swissknife (Sexton) on Jun 30, 2014 at 14:20 UTC | |
|
Re: perl grep with regex
by LanX (Saint) on Jun 30, 2014 at 12:37 UTC | |
|
OT: if loop (was Re: perl grep with regex)
by roboticus (Chancellor) on Jun 30, 2014 at 12:55 UTC | |
by swissknife (Sexton) on Jun 30, 2014 at 13:41 UTC | |
by jeffa (Bishop) on Jun 30, 2014 at 14:42 UTC |