Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: 'reversing' a hash

by thealienz1 (Pilgrim)
on Jun 18, 2003 at 17:07 UTC ( #266905=note: print w/replies, xml ) Need Help??


in reply to 'reversing' a hash

Change the

%ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);

to to

%ERRORS=('DEPENDENT'=>4,'UNKNOWN'=>3,'CRITICAL'=>2,'WARNING'=>1,'OK'=>0);

maybe I missing more of what your question is.

Replies are listed 'Best First'.
Re: Re: 'reversing' a hash
by Tomte (Priest) on Jun 18, 2003 at 17:13 UTC

    use Data::Dumper; %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=> +4); %ERRORS_TEXT = reverse %ERRORS; print Dumper(\%ERRORS); print Dumper(\%ERRORS_TEXT); __END__ $VAR1 = { 'WARNING' => 1, 'CRITICAL' => 2, 'OK' => 0, 'DEPENDENT' => 4, 'UNKNOWN' => 3 }; $VAR1 = { '1' => 'WARNING', '4' => 'DEPENDENT', '0' => 'OK', '3' => 'UNKNOWN', '2' => 'CRITICAL' };

    Get it?
    I use this to refer to the cleartext-error-code I get as exit-status of a sub-process.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

      Got it...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2019-10-17 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?