in reply to Re: Shorthand for /^\s*abc\s*$/ ?
in thread Shorthand for /^\s*abc\s*$/ ?
Running it: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}->(); } }
$ perl regexes.pl abc uep cmc aaa foo bar got 'abc'! got 'uep'! got 'cmc'! got 'aaa'!
|
|---|