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;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.