$string = 'www.perlmonks.org.split.reduce.code.check'; print join " ", reverse( $string =~ /(\w+)/g); $, = " "; print reverse (split /[.]/, $string); my $out; $out = "$_ $out" for split /[.]/, $string; # Extra space at the end though print $out;