in reply to Re: match exclude
in thread match exclude

Perhaps I should have given a bit more in the list

abe-n-s00008 redhat-release 5.11.0.4 abe-n-s00008 redhat-release-notes 52 abe-n-s00009 redhat-release 5.11.0.4 abe-n-s00009 redhat-release-notes 52 abe-n-s00010 redhat-release 5.11.0.4 abe-n-s00010 redhat-release-notes 52 abe-n-s00070 redhat-release 5.11.0.4 abe-n-s00070 redhat-release-notes 52 abe-n-s00070 redhat-release-server 6.8.0.5.el6

Redhat-release can also be redhat-release-server

What I want to exclude is redhat-release-notes

Replies are listed 'Best First'.
Re^3: match exclude
by hippo (Archbishop) on Mar 17, 2017 at 09:26 UTC

    Yes, that was the missing data - thank you. I still don't see the need for smartmatch. Instead, here is an SSCCE using a standard m match with a negative look-ahead:

    use strict; use warnings; use Test::More; my @good = ( 'redhat-release', 'redhat-release-server' ); my @bad = ( 'redhat-release-notes', 'any-old-nonsense' ); my $re = qr/^redhat-release(?!-notes)/; plan tests => @good + @bad; for my $str (@good) { like ($str, $re, "$str matched"); } for my $str (@bad) { unlike ($str, $re, "$str not matched"); }

    See How to ask better questions using Test::More and sample data for thoughts about presenting questions in this form.