the_Don has asked for the wisdom of the Perl Monks concerning the following question:
Here is the problem:
I am decrypting a file. I am using a module/script that was not written by me nor is the original author redilay available for assistance. At one point there is a matching operation that fails for one file, but passes for another, but the only thing that chagnes is the filename. The status messages from GnuPG are identical, the file contents are identical... only the extension of the file changes.
For your review, the sections of code that are in question, in the order in which they are encountered:
Section 1
my $new_filename = $full_filename; $new_filename =~ s/(\.gpg)|(\.encrypted)/\.decrypted/;
$error ||= "Unexpected signer '$signer' is not '$expected_sender'." unless ($signer =~ m/\Q$expected_sender\E/);
The file that results in the m// making setting an error is when I use a file named 'FILE.gpg' or 'FILE.encrypted'. If I decrypt a file named 'FILE.pgp' the m// in section 2 does not create an error.
I ran the script and printed out the contents of the variables before the m// is executed and regardless of file name (assuming the contents are identical) it is something similar to the following (I will change the key info since this is private material):
$signer = 'GOODSIG 86125876138571635 ClientKey'
$expected_signer = '';
Thus the following command is evaluated regardless of filename:
yet sometimes an error is created, sometimes not.$error ||= "Unexpected signer 'GOODSIG 86125876138571635 ClientKey' is + not ''." unless ('GOODSIG 86125876138571635 ClientKey' =~ m/\Q\E/);
My only thoughts is that when I pass a file name that results in a match in Section 1 something is set internally in perl that causes the match in Section 2 to set the error, but this is deductive reasoning, not solid knowledge of perl. And that is what I am hoping to gain - an understanding of how perl works so I can solve this problem.
the_Don
...making offers others can't rufuse.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression gotchas ?
by sauoq (Abbot) on Feb 14, 2003 at 22:45 UTC | |
by the_Don (Scribe) on Feb 17, 2003 at 08:13 UTC | |
by hv (Prior) on Feb 17, 2003 at 13:43 UTC | |
by the_Don (Scribe) on Feb 18, 2003 at 22:18 UTC | |
by hv (Prior) on Feb 18, 2003 at 22:50 UTC | |
|
Re: Regular Expression gotchas ?
by jdporter (Paladin) on Feb 14, 2003 at 21:55 UTC | |
by the_Don (Scribe) on Feb 14, 2003 at 22:16 UTC | |
by jdporter (Paladin) on Feb 14, 2003 at 22:28 UTC | |
by the_Don (Scribe) on Feb 17, 2003 at 16:00 UTC |