Hello Monks. Perl noob here and already learned a lot from these forums. Thanks for the responses in my previous post. Below are my Perl/System details

pgp->perl -v This is perl, v5.10.1 (*) built for aix-thread-multi pgp->perl -V Summary of my perl5 (revision 5 version 10 subversion 1) configuration +: Platform: osname=aix, osvers=6.1.2.0, archname=aix-thread-multi uname='aix powerpc unknown aix ' config_args='-desr -Dinstallprefix=/usr/opt/perl5 -Dprefix=/usr/op +t/perl5 -Dcc=xlc_r -Duseshrplib -Dusethreads' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef

I am trying to automate some PGP encryption/decryption and I have a situation. I am saving the output of certain PGP commands with something like this. Now in case of errors, the following set of strings would show up in the output.

3001:input file not found 1080:no private key could be found for decryption 1053:signing key not found 3013:no keys found 3011:invalid passphrase specified 3011:invalid passphrase specified 3090:operation failed, file not found 3028:multiple inputs cannot be sent to a single output file

When I try to compare the outputs with the strings, I am having issues. If I use a single string like "successfully" I am able to use the ~~ operator in Perl V5.10.1 How do I leverage ~~ operator with multiple strings?

$program_output3 = `pgp --<various arguments>`; if($program_output3 ~~ /"file wiped successfully"/i) { print "File encrypted successfully\n"; } elsif($program_output3 ~~ /"operation failed, file not found"/i) { print "signing key is not found?"; } elsif($program_output3 ~~ /"no keys found"/i) { print "Please check if the customer's signing key exists on our ri +ng"; }

I even tried creating an array with the error codes and loop through that array and compare with program output with ~~. Still no luck. Problem with trying to use something else like "List::MoreUtils qw" is that I cannot install any new modules on this server. (Due to various reasons that I cannot explain)


In reply to Perl 5.10.1 - compare external program output with a list of known error codes by malokam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.