![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Be careful with local $/ = \$maxlength;. That changes what the diamond operator thinks of as a line. If the input stream contains "foo\nbar\nbaz", then the line read will have as many "\n" as $maxlength will contain. You may want to keep the default record seperator and limit length with something like this:
Update: graff is right that this does not avoid problems with extra-long lines. Buffer overflow should not be a problem on most OS's, but forcing the machine into swap and OOM could be an attack. After Compline, In reply to Re: Read a line with max length ?
by Zaxo
|
|