>perl -wMstrict -le "$ARGV[$#ARGV] =~ m{ (\S) \s* \z }xms; my ($lastchr, $lastpos) = defined $1 ? ($1, $-[1]) : ('absent', -1); print '----- output -----'; print qq{last non-ws char is '$lastchr' at index $lastpos}; " "Message Line 1" "Message Line 2" "Message Line 3" "Prompt: " ----- output ----- last non-ws char is ':' at index 6