my $str1 = "2L"; # want to capture 2L my $str2 = "bar.2L"; #want to capture 2L #### while() { /\w*\.*(\S+)/; print "$1\n"; } __DATA__ 2L bar.2L