in reply to Breaking up a really long string
The solutions others have presented are way too complex.
while (my ($block) = $var =~ /(.{1,$max_length})/gs) { ... }
Note that it's very bad to use $&. It slows down every regexp with no captures in your program.
Update: It a better way of doing the same thing as FunkyMonk's, johngg's, caelifer's, almut's and jwkrahn's code, but our code doesn't do exactly the same thing as yours.
|
|---|