I am totally confounded by what appears to be a bug in the "does file exist"
functionality.

 

Here is the code as it stands now:

my $tmpfile = substr ($file, 0, index($file, ".pgp"));

print cwd();         ## debug code: to make sure we're in the correct
directory

chomp($tmpfile); ## debug code: Added this to see if there was any thing
funny in the file name.

            if (-e $tmpfile) {

#          if (-e "$tmpfile"){ ##This doesn't work

#          if (-e "F0715PAY.TXT") { ## This does work, but it needs to be a
variable

                        ## Do magic stuff to file. 

} else {

## Send error message

}

 

I stepped through the code with the debugger for the above snippet and this
is what I got (with a few minor edits for clarity sake)

 

The following files were found in directory: F0715PAY.TXT.pgp,
J0715PAY.TXT.pgp, C0715PAY.TXT.pgp

main::(rmain.pl2): my $tmpfile = substr ($file, 0, index($file, ".pgp"));

DB<> n

DB<> x $tmpfile

0 'F0715PAY.TXT.pgp'

DB<> /xfer/test/RDY

main::(rmain.pl2): chomp($tmpfile);

DB<> n

main::(rmain.pl2): if (-e $tmpfile) {

DB<> x $tmpfile

0  'F0715PAY.TXT'

DB<> n

main::(rmain.pl2): LogMsg (MSG => "Couldn't find $F0715PAY.TXT", Echo =>
$debug);

 

In a nutshell:

If I hard code in a file that I know exists, then the conditional (-e
filename) comes back true.

If that same file name is passed to the conditional in variable form, then
(-e $filename) and (-e "$filename") returns false.

I also tried passing in the full path name, with no success.

Yes, I do have permissions to read the file.

The OS is AIX UNIX if that makes any difference.

 

The "Send error message" includes email notification that the PGP
unencryption didn't work, so it's critical I don't just blindly assume that
the PGP decryption worked.

The "Do magic stuff" includes zipping and archiving the PGP file of to an
archive directory.

 

Any thoughts you anyone has would be greatly appreciated.

 

Tim

Reply via email to