sub proc{ my ($file) = @_; # (...) my $pathC = $path . "/$file"; open my $input, "zcat $pathC|" or do { print STDERR "\n!!ATTENTION:\n\tUnable to run zcat: $!\n"; return; }; while (my $line = <$input> ){ # (...) data proccessing irrelevant to the problem } # Not needed. Will happen automatically # when $input goes out of scope. #close($input); }