in reply to Break sentence into two part
Code reuse ;-)
#!/usr/bin/env perl use strict; use warnings; use List::MoreUtils qw(natatime); use feature qw (say); my @sentence = split / /, qq(Perl 5 is a highly capable, feature-rich programming language with +over 27 years of development); my $iterator = natatime scalar( @sentence / 2 ) + 1, @sentence; while ( my @half = $iterator->() ) { say join " ", @half; } __END__ karls-mac-mini:monks karl$ ./1114336.pl Perl 5 is a highly capable, feature-rich programming language with over 27 years of development
See also Re: writing array as pairwise and List::MoreUtils.
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|