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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |