Check out perldoc perlvar and you'll get some explanations about Perl's "special variables." Here is a quick sniglet from that doco:

        The variables $@, $!, $^E, and $? 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
       correspond to errors detected by the Perl interpreter, C library,
       operating system, or an external program, respectively.

Digging deeper into your question, here is what the doco says about $!:

       $!      If used numerically, yields the current value of the C "errno"
               variable, or in other words, if a system or library call fails,
               it sets this variable. This means that the value of $! is
               meaningful only immediately after a failure:

                       if (open my $fh, "<", $filename) {
                               # Here $! is meaningless.
                               ...
                   }
                   else {
                               # ONLY here is $! meaningful.
                               ...
                               # Already here $! might be meaningless.
                   }
                   # Since here we might have either success or failure,
                   # here $! is meaningless.

               The meaningless stands for anything: zero, non-zero, "undef". A
               successful system or library call does not set the variable to
               zero.

               If used as a string, yields the corresponding system error
               string. You can assign a number to $! to set errno if, for
               instance, you want "$!" to return the string for error n, or
               you want to set the exit value for the "die()" operator.

               Mnemonic: What just went bang?

and what it says about %!
       %!      Each element of "%!" has a true value only if $! is set to that
               value. For example, $!{ENOENT} is true if and only if the
               current value of $! is "ENOENT"; that is, if the most recent
               error was "No such file or directory" (or its moral equivalent:
               not all operating systems give that exact error, and certainly
               not all languages). To check if a particular key is meaningful
               on your system, use "exists $!{the_key}"; for a list of legal
               keys, use "keys %!". See Errno for more information, and also
               see "$!".

               This variable was added in Perl 5.005.
which is what the syntax your cite is working with.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

In reply to Re: Perl syntax question by blue_cowdawg
in thread Perl syntax question by Anonymous Monk

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.