jose_m has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I have a hash table which i am using to loop though a set of filenames to sub routines. The purpose is to run a sub if a file is not there. there are 6 different files and each need a unique action to be triggered based on the files existence. The problem is that the condition is failing. OK enough talk here is the code
%FileToFunction = ( "$file1", 'emailalert1', "$file2", 'emailalert2', +"$file3", 'emailalert3', "$file4", 'emailalert4', "$file5", 'emailale +rt5', "$file6",'emailalert6' ); foreach my $key ( keys %FileToFunction ) { my $value = $FileToFunction{$key}; print "checking $path$key\n\n"; if (-e "$path$key") { print " it exists $path$key\n\n"; print " found ....: $value\n\n"; } else { print " could not find file $path$key generating alert running +sub for $value\n\n\n"; &$value; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: file check not working
by toolic (Bishop) on Oct 07, 2014 at 12:39 UTC | |
by jose_m (Acolyte) on Oct 07, 2014 at 13:09 UTC | |
by Corion (Patriarch) on Oct 07, 2014 at 13:23 UTC | |
by jose_m (Acolyte) on Oct 07, 2014 at 17:12 UTC | |
by Anonymous Monk on Oct 07, 2014 at 21:28 UTC | |
by karlgoethebier (Abbot) on Oct 08, 2014 at 09:54 UTC | |
|
Re: file check not working
by Corion (Patriarch) on Oct 07, 2014 at 12:34 UTC | |
|
Re: file check not working
by jellisii2 (Hermit) on Oct 07, 2014 at 15:05 UTC |