in reply to Counting characters in a string

Here's another method if you're running perl 5.8.0 or better:

$str = "this is just a test\nthis is another test\nthis is yet another + test\n"; open F, "<", \$str or die; # open a handle to our string $/ = \5; # Read 5 characters at a time while (<F>) { # Read 'em! print "$_\n"; }