open my $FILE, "<", $input or die "cannot open $input: $!\n"; while (my $tag = <$FILE>) { . . . } close $FILE;