I have a long string of characters (> 40,000 chars) that I need to break up into strings of 6 chars each. Is there a simple way to do this in Perl? unpack() doesn't seem to be the right solution; there are no terminations for the strings I'm after.
Have I actually found something that is easier in C than in Perl?
You just want it broken up first 6 chars, then next 6 chars and so forth?
This will work:
#!/usr/bin/perl -wT
my $s = 'abcdefghijklmnopqrstuvwxyz0123';
foreach my $f ( $s =~ m!......!g ) {
print "'$f'\n";
}Note that if the string is not a multiple of 6 chars, the last few characters will be lost.
Enjoy, Peter.
-- <http://www.interarchy.com/> <http://documentation.interarchy.com/>
