in reply to split with a delimiter, every 4 time it occurs.

Are you the same person who asked Seeking help with split!? The questions are close enough that the same solutions will apply, with minor modifications, which are left as an exercise for the student.

By the way, have you taken a look at the contents of $to_split? The way you're defining it, it will contain only 'A'.


Dave

Replies are listed 'Best First'.
Re^2: split with a delimiter, every 4 time it occurs.
by Anonymous Monk on Jul 01, 2013 at 06:45 UTC

    Yes,

    Actually I tried the same solution by modifying it but it is not working! I am not good in Perl. Can you pls suggest me a way out.

    Here is my code,

    my $to_split = 'A','B','C','D','E','F','G','H','I','J','K','L','M','N' +,'O','P','Q','R','S','T','U','V','W','X','Y','Z'; my @ra = split m{ (?: \',\' [^\',\']+){50} \K \',\' }xms, $to_split ; + foreach my $piece(@ra){ print "\n\n" . $piece . "\n\n"; }

    Can you pls suggest me where I got wrong?

    Thanks in advance.

      "I am not good in Perl.

      None of us were, when we first studied (formally or otherwise) how to write in Perl. So what have you done to "suggest (yourself) where (you) got wrong."

      And, again re "not good in Perl," presumably, that's why this homework was assigned... to give you a problem you can solve by applying what you've learned previously, and with judicious study of the relevant documents.

      If you didn't program your executable by toggling in binary, it wasn't really programming!

Re^2: split with a delimiter, every 4 time it occurs.
by Anonymous Monk on Jul 01, 2013 at 06:50 UTC

    There is an edit!!!

    my $to_split = "'A','B','C','D','E','F','G','H','I','J','K','L','M','N +' +,'O','P','Q','R','S','T','U','V','W','X','Y','Z'";

    Thanks