in reply to How to make sure no elements from @array are inside $scalar

Wow, thanks to all for your responses! Again learned a lot by reading through your answers. I think in the end it's a matter of taste, I personally like the List::Utils way best. Also new to me was the comma operator - really handy!

if ($text =~ /_9(...)/, none {$1 eq $_} @$sites) { print "To be remove +d..\n" }

Replies are listed 'Best First'.
Re^2: How to make sure no elements from @array are inside $scalar
by Anonymous Monk on Nov 14, 2014 at 16:06 UTC
    Notice that your chosen solution will only use the first match in $text that starts with '_9', so it won't work with something like 'f000124_9019_90181234_dp'.
    use List::Util qw( none ); my $text = 'f000124_9019_90181234_dp'; my $sites = [ '018', '324' ]; if ($text =~ /_9(...)/, none {$1 eq $_} @$sites) { print "$1 doesn't match anything: to be removed..\n" }
    Output:
    019 doesn't match anything: to be removed..
    This isn't how your original code worked.

      Yes you're perfectly right, thanks for mentioning it. However I haven't told that the strings I need to check have a rather static format of:

      <userid>_<8-digit-number-starting-with-9>_dp