I think Errno does what you require. Additionally, you can search for the file Errno.pm on your computer and see what's locally available.

Update: Ok, I misunderstood your question. The following is ultra-fragile, but works here (YMMV):

use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my %h_error_symbol; # maps errno to symbol my %h_error_text = ( NETDB_INTERNAL => "See errno.", NETDB_SUCCESS => "No problem.", HOST_NOT_FOUND => "Authoritative Answer Host not found.", TRY_AGAIN => "Non-Authoritative Host not found, or SERVERFAIL +.", NO_RECOVERY => "Non recoverable errors, FORMERR, REFUSED, NOTIM +P.", NO_DATA => "Valid name, no data record of requested type.", NO_ADDRESS => "No address, look for MX record.", ); # we later try to find a mapping errno-->symbol open my $errdb, '<', '/usr/include/netdb.h' or die; while (my $line = <$errdb>) { if (my ($symbol, $val) = $line =~ /^\s*\#\s*define\s+([^_]\w+)\s+(-? +\d+)/) { next unless exists $h_error_text{$symbol}; # skip irrelevant symbo +ls die "FATAL: $symbol = $val - conflicts with $h_error_symbol{$val} +\n" if exists $h_error_symbol{$val}; $h_error_symbol{$val} = $symbol; } } close $errdb or die; sub hstrerror { my $errno = shift; return exists $h_error_text{$h_error_symbol{$errno}} ? $h_error_text{$h_error_symbol{$errno}} : "other h_error \#$errno"; } sub h_error_symbol { my $errno = shift; return exists $h_error_symbol{$errno} ? $h_error_symbol{$errno} : "GENERIC_H_ERROR_$errno"; } # Demo: print "Example: 1 -> ", h_error_symbol(1), " / ", hstrerror(1), "\n"; print Dumper(\%h_error_symbol);
Example: 1 -> HOST_NOT_FOUND / Authoritative Answer Host not found. $VAR1 = { '-1' => 'NETDB_INTERNAL', '0' => 'NETDB_SUCCESS', '1' => 'HOST_NOT_FOUND', '2' => 'TRY_AGAIN', '3' => 'NO_RECOVERY', '4' => 'NO_DATA' };


In reply to Re: h_errno constants? by Perlbotics
in thread h_errno constants? by tlhackque

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.