in reply to Can split split against more than one character in a string of the same character?

No need to mess with split when you just want to divide up a string of the same chars:

use strict; use warnings; use Test::More tests => 1; my $in = 'aaaaaaaaa'; my $want = 'aa aa aa aa a'; my $have = join ' ', ($in =~ /a{1,2}/g); is $have, $want;
  • Comment on Re: Can split split against more than one character in a string of the same character?
  • Download Code

Replies are listed 'Best First'.
Re^2: Can split split against more than one character in a string of the same character?
by Don Coyote (Hermit) on Jul 15, 2019 at 22:29 UTC

    I had an inkling that split could do this, but was approaching it from too complicated a place. Starting to get the feeling I should have perldoc -f split now.

    This is a clean and efficient way of doing this with match though, thanks

    I like the simplicity of the test structure, allowing for documenting attempts. That's really great.