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