$ perl -le ' > @strs = ( q{abcd }, q{abcdef}, q{ } ); > print qq{String: >$_< - }, > m{(?=(\S)\s*$)}g > ? qq{found $1 at offset @{ [ pos() ] }} > : q{no match} > for @strs;' String: >abcd < - found d at offset 3 String: >abcdef< - found f at offset 5 String: > < - no match $