Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (regular expressions)
I'm trying to get the effect of grep(!/re/, @array) with the /re/ saved in a variable. Nothing that I try seems to work. I don't find that there is any way to place the inversion within the regex variable, so I guess that it needs to go in the grep call. Starting with $tmp=qr/pattern/; I've tried grep(!$tmp, @array); and grep(! $tmp, @array); (that has a space added) and grep {! $tmp} @array;, but no joy. What variation would work?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Invert grep match with qr// variable⭐
by hv (Prior) on Feb 06, 2024 at 18:27 UTC | |
by ikegami (Patriarch) on Feb 06, 2024 at 22:15 UTC | |
by Dallaylaen (Chaplain) on Feb 07, 2024 at 10:04 UTC | |
|
Re: Invert grep match with qr// variable
by Corion (Patriarch) on Feb 06, 2024 at 16:33 UTC | |
by ikegami (Patriarch) on Feb 06, 2024 at 22:10 UTC | |
|
Re: Invert grep match with qr// variable
by ikegami (Patriarch) on Feb 06, 2024 at 22:08 UTC |