Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Break sentence into two parts

by Athanasius (Archbishop)
on Jan 24, 2015 at 07:43 UTC ( [id://1114342]=note: print w/replies, xml ) Need Help??


in reply to Re: Break sentence into two part
in thread Break sentence into two part

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,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1114342]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found