in reply to How can I split a string into chunks of 4 characters

$_ = '01234567890'; push @a, $1 while s/(.{1,4})//;
update
didn't read the task properly. my bad sorry
new solution:
$_ = '01234abc'; $_ = $2.$', push @a, $& while /(.)(.{3})/;

Replies are listed 'Best First'.
Re^2: How can I split a string into chunks of 4 characters
by davido (Cardinal) on Dec 06, 2013 at 20:27 UTC

    "push @a, $1 while s/(.{1,4})//;" produces the following: "0123 4abc", which is not the desired result.


    Dave

      i will cite the author
      "For example, string "01234abc" would become array 0123 4abc"
      it is exactly what my script does
      you sir, I suppose, didn't read the task

      got mistaken. im sorry

        From the OP:

        For example, string "01234abc" would become array ("0123", "1234","234a","34ab","4abc")

        Perhaps PetreAdi made an uncited alteration to the post, but the quoted example output data is what I remember seeing when I first read it.