in reply to regex and sysread

sysread is normally used for reading binary stuff, NOT line by line normal text stuff.
Perl is THE "black-belt" language for processing text.
while (my $line = <>) { # do someting with $line which was \n # terminated. (or in Windows \r\n terminated) # Perl figures that difference out for you. }