$/ = '>'; # throw away first (junk) record defined(<$fh>) or ($! and die "reading: $!"); while (defined(my $record = <$fh>) or ($! and die "reading: $!")) { $record =~ s{ \n }{}xmsg; process($record); } #### while (defined(my $record = <$fh>) or ($! and die "reading: $!")) { chomp $record; # remove $/ string $record =~ s{ \n }{}xmsg; process($record); }