in reply to Matching n characters with m//g
substr is so much simpler here.
while( $sz > 32760 ) { print $FH substr($m, pos($m), 32760); pos($m) += 32760; $sz -= 32760; } print $FH substr($m, pos($m), $sz); pos($m) += $sz;
Or if you don't mind destroying $m,
while( $sz > 32760 ) { print $FH substr($m, 0, 32760, ''); $sz -= 32760; } print $FH substr($m, 0, $sz, '');
But I fail to see how those are any different than just
print $FH substr($m, pos($m), $sz); pos($m) += $sz;
and
print $FH substr($m, 0, $sz, '');
|
|---|