At work I learned about a tool called perror, that showed the literal string corresponding to a numeric UNIX error. So if you get a message from a program that says "errno 13", you can run perror to easily translate that into "Permission denied". When I went to install it at home, I found out that it's in Debian package mysql-server (!). So I made my own version:

foreach (grep /^\d+$/, @ARGV) { $! = $_; print "$_: $!"; }

Which can be turned into a oneliner:

$ perl -le'print "$_: ", $! = $_ foreach grep /^\d+$/, @ARGV' 13 20 +## It even respects your locale settings 13: Permiso denegado 20: No es un directorio

--
David Serrano


In reply to perror.pl by Hue-Bond

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.