perl_lover has asked for the wisdom of the Perl Monks concerning the following question:

$\ = "\n"; for($!=0;$!<=87;$!++) { print $!; }

This code prints all the error string. How does Perl maps this errorno. to error string ?
update : I am running perl, v5.6.1 on a freeBSD box

Replies are listed 'Best First'.
Re: How Perl Maps error no. to error string
by ikegami (Patriarch) on Aug 17, 2006 at 05:03 UTC
    $! is probably errno when used in numerical context, and strerror(errno) when used in string context.
Re: How Perl Maps error no. to error string
by GrandFather (Saint) on Aug 17, 2006 at 04:18 UTC

    I suspect that is internal magic and you are not supposed to know. Very likely it is OS, or even build, specific. I only get 43 valid error strings using your test code. The rest are flagged as "Unknown error". (AS Perl version 5.8.7)


    DWIM is Perl's answer to Gödel
Re: How Perl Maps error no. to error string
by jesuashok (Curate) on Aug 17, 2006 at 04:28 UTC
    Hi perl_lover

    The variables $@, $!, $^E, and $? are called as error indicators in perl. These variables also contain information about different types of error conditions that may appear during execution of a Perl program. The variables are shown ordered by the "distance" between the subsystem which reported the error and the Perl process. They corre- spond to errors detected by the Perl interpreter, C library, operating system, or an external program, respectively.

    $! is set to the C library's "errno" which inturn mapped to error string in perl compiler.

    For more information on this indicators refer perlvar

    "Keep pouring your ideas"
A reply falls below the community's threshold of quality. You may see it by logging in.