Yes, that’s how I would approach the problem. But there’s no need to populate new arrays using push, etc.: just use array slices directly:
my $first_half = join(' ', @words[0 .. $midpoint]); my $second_half = join(' ', @words[$midpoint + 1 .. $#words ]);
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^2: Break sentence into two parts
by Athanasius
in thread Break sentence into two part
by Mjpaddy
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |