leons has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
How can I easily split a certain string ... Let's say:
Into n-character parts, without using a regex. The only thing
I came up with was (assuming I'd want 2-character parts):
Because I really don't want to use a regex or a while-loop
Thanks a Lot,
Bye, Leon
How can I easily split a certain string ... Let's say:
my $string='aabbccddee';
Into n-character parts, without using a regex. The only thing
I came up with was (assuming I'd want 2-character parts):
Which would result in @row being:push @row,$& while('aabbccddee'=~/\w{2}/g);
Is there a better way ... i.e. by using split or map or whatever ?@row=('aa','bb','cc','dd','ee');
Because I really don't want to use a regex or a while-loop
Thanks a Lot,
Bye, Leon
Back to
Seekers of Perl Wisdom