$file=''; open(IN,"<$filename") || die "$file can't be opened: $!"; { local $/=undef; $file=; } @lines=split /[\r\n]+/, $file; foreach $line (@lines) { # do some processing here }