Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

On *nix, the value returned by system doesn't necessarily reflect an OS error

Which is a common newbie error. They check the value of $! inappropriately after system. According to perlvar, $! (or $^E on some systems) will have useful information after system or backticks if (and only if) $? == -1. Hence the check.

What distinct information is available on exit from a VMS, Win32 or OS/2 system call? How much different are the extended error returns?

system returns the same. However, system may fail with $? = -1 when the child process fails due to an OS error. $! is C's errno, but on VMS, Win32, and OS/2 the underlying API provides it's own error messages which C's errno does not reflect. On these systems $^E holds that value (see perlvar for the specific API calls made to get that value). This is a workaround for the fact that Perl and C are still a bit *nix centric. $^E exists for people who aren't on *nix systems while still allowing *nix programmers on Windows or the like still get what they expect from $!.

Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


In reply to Re: Re: RFC: Shell::DWIM by erikharrison
in thread RFC: Shell::DWIM by erikharrison

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-16 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found