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

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.

Replies are listed 'Best First'.
Re^3: How to make sure no elements from @array are inside $scalar
by Steffen (Novice) on Nov 14, 2014 at 17:18 UTC

    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