in reply to How to grep for a filename for each of the keys of a hash

$filename is not a regular expression, use eq

The metacharacter . will match a space

use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/\s(.:.+?)/ )->explain; __END__ The regular expression: (?-imsx:\s(.:.+?)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- \s whitespace (\n, \r, \t, \f, and " ") ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- : ':' ---------------------------------------------------------------------- .+? any character except \n (1 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Space, followed by notSpace, at the end of the string, ie /\s(\S+)$/ or /\s(\S+)\z/

or with substr/rindex

$ perl -le"my $f = q!a b c d ee!; print substr $f, 1+rindex $f, q! !" ee