otherwise its value doesn't mean anything at all.
Isn't "at all" too strong here? $! (i.e. errno is initially zero (as far I remember, this is guaranteed by the C standard), and gets a non-zero value if someone sets it - for instance, in a failed system call or if in Perl it is explicitly set by assignment. Seeing it only this way, the value of $! picked up somewhere in the middle of a program execution indeed doesn't mean much.

But here we have a different situation: We see that in the program

perl -lwe "print $!"
$! is zero, which means that when Perl starts executing a (correct) program, $! happens to be zero. We also see that for instance
perl -lwe "use warnings; print $!"
print zero, so just the fact that Perl has to compile a pragma, doesn't change the value of $!. But we see that
perl -lwe "use strict; print $!"
prints a non-zero value, and from this I conclude that $! must be set somewhere somehow within strict.pm. Being a curious person, I had a look at the source of strict.pm. I didn't find a direct assignment to $! (which is no surprise - we wouldn't expect this anyway), and the system calls I found (and which could possibly set $! to a 'bad file descriptor' error number), are in blocks belonging to error handling (i.e. I would have seen an error message, if such a branch would have taken). That's why I was puzzled and became curious. I admit that it is only for academic interest and has not much practical value aside of satisfying my curiosity ;-)

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^4: "use strict" sets $! by rovf
in thread "use strict" sets $! by rovf

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.