if ( -s "/tmp/$strHostname/polling.txt") { my @ndmpselect; open ($fh8, "/tmp/$strHostname/polling.txt"); chomp (@dmpselect = (<$fh8>)); my %ndmphash; for (@dmpselect) { unless (exists $dmphash{$_}) { my $file = "/tmp/loc/" . $_ . '.txt'; open(my $fh, '>', $file) or die "Cannot open file '$file' for writing: $!"; $dmphash{$_} = $fh; } } }