in reply to Reading files, skipping very long lines...

What was your attempt with read() ? It takes a length to read, so you can read chunks at a time .. but i think you have to handle the line breaks yourself ...

Update: I started an attempt with read(), but hit a snag .. i think i need to restart my attempt and read 1 char at a time..
use strict; use warnings; use Data::Dumper; use constant MAX_LINE_LENGTH => 25; my $file = '/etc/hosts'; my @lines; my $prev_line = ''; while( !eof DATA ){ my $line; read DATA, $line, MAX_LINE_LENGTH; push @lines, $line; } print Dumper \@lines; __DATA__ this is a line aqwewqe short shrt short2 short3 this is a line asdas this is a another very ling line lkjkdsa to skip qweqweqwewqewqewqeqwe this is a line asdasd this is a line lkjqwe this is a very ling line lkjkdsa to skip qweqweqwewqewqewqeqwe this is a line ad as


Update2: Not overly impressive coding, but i think this works (i created a long ~7.8M line with for f in `seq 1 1000000` ; do echo -n "blahblahblah" >> /tmp/longline ; done in bash and stuck it in the DATA section and it seemed to work):
use strict; use warnings; use Data::Dumper; use constant MAX_LINE_LENGTH => 25; my $file = '/etc/hosts'; my @lines; my $line = ''; while( !eof DATA ){ my $c; read DATA, $c, 1; if( length($line) > MAX_LINE_LENGTH ){ $line = '' if $c eq "\n"; next; } if( $c eq "\n" ){ push @lines, $line; $line = ''; next; } $line .= $c; } print Dumper \@lines; __DATA__ this is a line aqwewqe short shrt short2 short3 this is a line asdas this is a another very ling line lkjkdsa to skip qweqweqwewqewqewqeqwe this is a line asdasd this is a line lkjqwe this is a very ling line lkjkdsa to skip qweqweqwewqewqewqeqwe this is a line ad as