Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perl 5.10.1 - compare external program output with a list of known error codes

by choroba (Cardinal)
on Sep 19, 2016 at 15:51 UTC ( [id://1172156]=note: print w/replies, xml ) Need Help??


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

You don't need the ~~ operator for simple matching, =~ is enough. Moreover, ~~ is experimental and will change or be removed in the future, so it's better to stay away from it.

Also, when matching against a regex, don't include double quotes in it, as they are interpreted literally, but your strings don't contain them. The slashes are already the delimiters, no need for anything else.

You can use the | alternative operator inside a regex:

#!/usr/bin/perl -- use warnings; use strict; use feature qw{ say }; while (<DATA>) { if (/no private key could be found for decryption|signing key not +found|no keys found/) { say 'Missing key(s)'; } elsif (/file not found/) { say 'File not found' } else { say 'Unknown error'; } } __DATA__ 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

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Perl 5.10.1 - compare external program output with a list of known error codes
by malokam (Novice) on Sep 19, 2016 at 19:08 UTC

    What is this part doing?

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      That's not doing anything in relation to the code he's specified for you. Anything below the solid black line is choroba's Perlmonks signature, like the signature in an email.

      Copy/paste it into a script.pl file, and run perl script.pl on it at the command-line, and you'll see what it does ;)

        OMG! I feel like an idiot..

        Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-19 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found