# guess to set $/ to correct linebreaks # untested code. local $/ = \1000; # read first 1000 bytes local $_ = <$file>; my $newline; for my $test ("\015\012","\015","\012") { # match various newline chars, default to unix $newline = $test; last if /$test/; } local $/ = $newline; seek $file,0,0; # rewind to start of file