while ("one.two.three" =~ /([A-Za-z0-9_].+)\.?([A-Za-z0-9_].+)?/g) { print "$1\n"; }