OK, took some finding but this might be the problem. The blank lines in your config file are creating a blank key entry in the %CONFIG_PARAMS hash i.e. "" => undef. When you loop through the keys at some point the match becomes
if ($file =~ //) { $mapattach = undef; }
Because the order is random it depend which keys follow as to whether it gets corrected. The fix is to add a line to skip the blanks lines in here
# parse the config file while (<FILE>) { # remove leading spaces $_ =~ s/^\s+//g; # remove trailing spaces $_ =~ s/\s+$//g; # ignore comments next if $_ =~ /^#/; # ignore blanks next unless /\S/; my @params = split /=/ , $_; $CONFIG_PARAMS{$params[0]}=$params[1]; }
A better way would be use a regex to extract the key from the filename and match directly like this.
pojmy $mapattach; # add () inside // to capture match if ($file !~ /($CONFIG_PARAMS->{'OUTCRIT'})/) { Println "Skipping $file, doesn't match $CONFIG_PARAMS->{'OUTCRIT'}"; next OUTBOUND; } else { $mapattach = $CONFIG_PARAMS->{$1}; }
In reply to Re^4: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
by poj
in thread Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
by Srinath
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |