in reply to 'reversing' a hash

This node falls below the community's threshold of quality. You may see it by logging in.

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...