in reply to Re: Help understand why this grep does not work
in thread Help understand why this grep does not work
DB<102> @data1 = ( "a 1 a", "a 2 T", "a 3 C" ); => ("a 1 a", "a 2 T", "a 3 C") DB<103> @data2 = ( "a 2 Y", "a 3 R", "a 4 Q", "b 5 R" ); => ("a 2 Y", "a 3 R", "a 4 Q", "b 5 R") DB<104> $regex = join "|" , map {/^(\w\s+\d)/} @data1 => "a 1|a 2|a 3" DB<105> grep { /^($regex)/ } @data2 => ("a 2 Y", "a 3 R")
think I spotted (and corrected) a bug in your logic, you forgot to anchor to string start '^' in your grep regex.
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Help understand why this grep does not work
by drmrgd (Beadle) on Nov 02, 2013 at 16:15 UTC | |
by LanX (Saint) on Nov 02, 2013 at 16:21 UTC | |
by drmrgd (Beadle) on Nov 02, 2013 at 16:46 UTC | |
by LanX (Saint) on Nov 02, 2013 at 16:59 UTC | |
by drmrgd (Beadle) on Nov 02, 2013 at 17:10 UTC |