in reply to Call for code samples!
And for /g, a thing to split up a block of text, preserving existing line breaks, but having a max line size:
Oh, and a '/g' example from a recent thread (of which you've probably already got something similar).print $1,"\n" while $text =~ /([^\n]{0,$max_line_size}})\n?/g;
And this thing which reads from a socket until I have an end-token on a line:
while ($sel->can_read) { sysread($fh, $buffer, 2048, length($buffer)); next unless $buffer =~ /^(EOT|DONE)$/m; ....(process $buffer) }
|
|---|