in reply to Split string after 14 Line Feeds?
A more general approach with "nested" iterators:
sub read_chunk { my ($fh,$mod) = @_; my $chunk; while ( <$fh> ) { $chunk .= $_; return $chunk unless $. % $mod; } return $chunk; } open my $fh, "<", \$string; while ( my $chunk = read_chunk( $fh, 14 ) ) { print $chunk; print "-"x5,"\n"; }
works with anything you can open via filehandle even strings.
Cheers Rolf
|
---|
In Section
Seekers of Perl Wisdom