develooper Front page | perl.beginners | Postings from October 2009

split n characters into n chunks

Thread Next
From:
Michael Alipio
Date:
October 25, 2009 02:43
Subject:
split n characters into n chunks
Message ID:
325255.88735.qm@web58302.mail.re3.yahoo.com
Hi,

How do I split a word into n subsets?

my $word = "thequickbrown"


If I want three subsets I should be able to create:

the
heq
equ
....
upto
....
own


Using split function with limit of 3 gives me:

t h equickbrown



Any idea how to do this? I'm thinking maybe I can just split the whole string and push each character into array, then loop through the array, getting 3 elements set in the proces..







      


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About