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

Re: split n characters into n chunks

Thread Previous | Thread Next
From:
mahesh bhasme
Date:
October 27, 2009 00:18
Subject:
Re: split n characters into n chunks
Message ID:
ab478eee0910270018y7ee02966j8d8244c89e5c731f@mail.gmail.com
Hi,

you can use substr $myword, 1,3  function

Thanks,
Mahesh
On Sun, Oct 25, 2009 at 3:13 PM, Michael Alipio <daem0nb0y@yahoo.com> wrote:

> 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..
>
>
>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>


-- 
Thanks,
MAhesh

Thread Previous | 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