in reply to Re: Shorthand for /^\s*abc\s*$/ ?
in thread Shorthand for /^\s*abc\s*$/ ?

I like this approach, AppleFritter, but it could perhaps be made slightly simpler (or maybe not simpler but only more concise):
use strict; use warnings; use 5.014; my %interesting; for (qw/ abc cmc uep a{3}/) { $interesting{$_} = sub { say "got '$_'!"}; } # process data and apply tests for (@ARGV) { foreach my $test (keys %interesting) { /^\s*$test\s*$/ and $interesting{$test}->(); } }
Running it:
$ perl regexes.pl abc uep cmc aaa foo bar got 'abc'! got 'uep'! got 'cmc'! got 'aaa'!