use Cwd; my $path=cwd(); sub proc{ my ($file) = @_; # (...) $pathC = $path . "/$file"; open INPUT, "zcat $pathC|" or dealError($cpath); while($line = ){ eval($line); # (…) data proccessing irrelevant to the problem } close INPUT; } sub init{ (...) #Initializing @lista ("system "ls"" plus a bunch of tests) for my $fileName (@lista){ proc($fileName); } } init; #------------------------------------------------------------------ sub dealError{ my ($path) = @_; open(STDIN, "-"); #Opens standard INPUT print "\n!!ATENTION:\n\tdealError: Could not open file $cpath\n"; print "Check the problem with the file and type GO to continue\n"; while($line = ){ if ($line =~ m/GO/){ open INPUT, "$cpath" or dealError($path); close STDIN; last; } else { print "Check the problem with the file and type GO to continue\n"; } } }