for (qw( video book )) { 'unchanged' =~ /(.*)/; # Set $1 if ( $_ !~ /(video)/ ) { print "true -> $1\n"; } else { print "false -> $1\n"; } } #### false -> video true -> unchanged #### foreach my $link ( 'The Bottled Water Lie', 'The Bottled Water Lie', ) { my ($url, $title) = $link =~ m{href="(.+)">(.+)} or next; $url =~ /video/ and next; print("$url: $title\n"); } #### foreach my $link ( 'The Bottled Water Lie', 'The Bottled Water Lie', ) { my ($url, $title) = $link =~ m{href="((?:(?!video).)+)">(.+)} or next; print("$url: $title\n"); }