or download this
$ perl -MData::Dumper -le '%h = map { $_ => /^FOO((?!BA[RZ]$).*)/ ? $1
+ : q(does NOT match) } qw/FOO FOOZIM FOOBAR FOOA FOOBAZ FOOBARX/; $Da
+ta::Dumper::Terse = $Data::Dumper::Indent = 1; print Dumper \%h'
{
...
'FOOBAZ' => 'does NOT match',
'FOO' => ''
}