Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

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

Win32 Perl has always had GetModulePathName() which means that Perl on Win32 will always have an absolute path for $^X. I think that Linux now has similar functionality.

However, other Unix platforms don't have a reliable way for an executable to figure out its filename. A Unix executable just gets argv[0] which can have absolutely nothing to do with the name of the executable. argv[0] will often be a path string that an algorithm like that used (perversely) by FindBin could be used to find the executable path.

If you want to know what happens on those platforms, I'd look at Perl's source code rather than try to conduct a poll.

Update: Here is the best way to prevent Perl from setting $^X to a real path:

system $^X "notPerl", '-le', 'print $^X'
which will produce "notPerl" on most non-Linux Unix platforms (and probably even on Linux for not-the-latest releases of Perl) but will produce the full path to your Perl executable on Win32 (even Win95).

- tye        


In reply to Re: Poll: Is your $^X an absolute path? (argv[0]) by tye
in thread Poll: Is your $^X an absolute path? by xdg

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 exploiting the Monastery: (4)
As of 2024-04-25 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found