#! perl use strict; use warnings; my %searches = ( bar => " bar \n\n", foo => " foo c \n", ); for (sort keys %searches) { print "$_: ", $searches{$_} =~ re($_) ? 'match' : 'no match', "\n"; } sub re { qr{ ^ \s* $_[0] \s* $ }x; } #### 23:06 >perl 1402_SoPW.pl bar: match foo: no match 23:06 >