open my $fh, '<', 'hostdata.txt' or die $!; while( my $hdb2 = <$fh> ){ # do stuff with $hdb2 } close $fh;