use strict; use warnings; my $sentence = 'Perl 5 is a highly capable, feature-rich programming language with over 27 years of development.'; my @words = split( ' ', $sentence); my $midpoint = sprintf("%d", scalar @words / 2); my ( @first_half, @second_half ); my $count = 0; for ( @words ) { push @first_half, $_ if $count <= $midpoint; push @second_half, $_ if $count > $midpoint; $count++; } print join( ' ', @first_half ) . "\n"; print join( ' ', @second_half ) . "\n";