http://qs321.pair.com?node_id=1182526


in reply to split string using optimized code or perl one liner

Is it about efficiency or number of lines? In the first case, you'll have to Benchmark a bunch of solutions. Otherwise, TIMTOWTDI.

$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 th +ough print $out;