Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3

by poj (Abbot)
on Feb 10, 2017 at 20:06 UTC ( [id://1181709]=note: print w/replies, xml ) Need Help??


in reply to Re: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
in thread Code Issue after Upgrading the perl from 5.14.4 to 5.22.3

Check out this config line

# Do not process any outbound files that do not match this criteria "|" is an OR condition
OUTCRIT=DSVASN|DSNO|ECPOAO|EPOCAC|EPOCAO|DSVINV|INO|DSVRMA|TGT865|TGTASN|ECPOAO|

ECPOAO appears twice but more important is the trailing | which makes the regex accepts any value of $file so none are skipped here.

241:     if ($file !~ /$CONFIG_PARAMS->{'OUTCRIT'}/) {
242:         Println "Skipping $file, doesn't match $CONFIG_PARAMS->{'OUTCR
+IT'}";
243:         next OUTBOUND;
244:     }

Note also ECPOAC=GIBo855CSFFEDI.att but ECPOAC does not appear in criteria

EPOCAO in criteria does no have assoc .att file

poj

Replies are listed 'Best First'.
Re^3: Code Issue after Upgrading the perl from 5.14.4 to 5.22.3
by Srinath (Initiate) on Feb 11, 2017 at 02:29 UTC

    hi poj

    I have corrected the config file and executed the script still the issue, if you notice the output for first run the script has picked the file and for the next run it failed, though the file is still available to process.

    Output

    $ ./aicallerbt -o 2017/02/11 07:44:19 [ 956] Outbound dir set to C:/AI_EDI/outbound/in 2017/02/11 07:44:19 [ 956] Total files found 1 2017/02/11 07:44:19 [ 956] Processing outbound file C:/AI_EDI/outbou +nd/in/TGTASN1234 2017/02/11 07:44:19 [ 956] Outbound Archive dir set to C:/AI_EDI/out +bound/BBBTGT/Inputarchive 2017/02/11 07:44:19 [ 956] WARN : Ignoring C:/AI_EDI/outbound/in/TGT +ASN1234, not found in the config file 2017/02/11 07:44:19 [ 956] E-mailing Outbound Document Report $ ./aicallerbt -o 2017/02/11 07:44:21 [ 5280] Outbound dir set to C:/AI_EDI/outbound/in 2017/02/11 07:44:21 [ 5280] Total files found 1 2017/02/11 07:44:21 [ 5280] Processing outbound file C:/AI_EDI/outbou +nd/in/TGTASN1234 2017/02/11 07:44:21 [ 5280] Outbound Archive dir set to C:/AI_EDI/out +bound/BBBTGT/Inputarchive 2017/02/11 07:44:21 [ 5280] "/bin/inittrans" -cs -at OTEnvelp.att -D +INPUT_FILE=C:/AI_EDI/outbound/in/TGTASN1234.cp -DMESSAGE=TGTo856FFEDI +.att -DBYPASS=OTINOByp.att -tl 0 -I 2017/02/11 07:44:21 [ 5280] sh: /bin/inittrans: No such file or direc +tory 2017/02/11 07:44:21 [ 5280] ERROR : Unable to open AI directory /appl +/

    ignore Error messaage, my only criteria is $mapattch value

      Your next step is to inspect what is in %CONFIG_FILE when you encounter that condition.

      Use the following code:

      if ($file =~ /$key/) { $mapattach = $value; use Data::Dumper; print Dumper \%CONFIG_FILE; }

      Also output whenever you get a match on /$key/:

      if ($file =~ /$key/) { $mapattach = $value; use Data::Dumper; print Dumper \%CONFIG_FILE; print "'$file' matches /$key/, setting value '$value'\n"; }

      Maybe there are two keys in %CONFIG_FILE that match the filename and the second one overwrites the first match in some cases? You are aware that hash keys are not ordered in Perl?

      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.

      my $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}; }
      poj

        Thank you Poj, Corion and all the Monks who took there valuable time to inspect code and gave the solution.

        Ignore blanks has worked for me.

        # ignore blanks next unless /\S/;

        Thanks & Regards

        Sri

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181709]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found