Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: path to perl interpreter

by rnahi (Curate)
on Sep 29, 2005 at 07:36 UTC ( #496006=note: print w/ replies, xml ) Need Help??


in reply to Re: path to perl interpreter
in thread path to perl interpreter

What you say does not agree to the docs and to my practice.

$ cat whichperl.pl #!/usr/bin/perl printf "operating system: %s\n executable: %s\n", $^O, $^X, ;

And see the results:

$ perl whichperl.pl operating system: linux executable: /usr/bin/perl $ chmod +x whichperl.pl $ ./whichperl.pl operating system: linux executable: /usr/bin/perl

And later, to another OS:

$ perl whichperl.pl operating system: freebsd executable: /usr/local/bin/perl


Comment on Re^2: path to perl interpreter
Select or Download Code
Re^3: path to perl interpreter
by kprasanna_79 (Hermit) on Sep 29, 2005 at 07:54 UTC
    Hi Mahi,

    Why cant you try it in unix machines.Any how good try with linux and freeBSD. But what i tried is with unix HP-UX B.11.11. Might be you check here if u can.

    More over i am fond of reading Perl in 21 days where this doc was described. May be you can check that and put your comments to the author of the book

    Update:-

    Since you are that much confident with your idea i need to give you the result what i got from your code

    perl -le 'print $^X' perl

    May be here according your code unix may performing wrongly. If so put a cc to unix group too apart from 21 days author.

    Prasanna.K

    Edit planetscape - removed link to copyrighted material

      Hi. My nick is rnahi, not "Mhai."

      You are referring to something that looks like copyrighted material with wrong information.

      Have a look at the official docs .

      $^X
      The name used to execute the current copy of Perl, from C's  argv[0] .
      Depending on the host operating system, the value of $^X may be a relative or absolute pathname of the perl program file, or may be the string used to invoke perl but not the pathname of the perl program file. Also, most operating systems permit invoking programs that are not in the PATH environment variable, so there is no guarantee that the value of $^X is in PATH.
        the value of $^X may be a relative or absolute pathname of the perl program file, or may be the string used to invoke perl but not the pathname of the perl program file.

        In that case, wheel out the heavy artillery.

        use Config; my $perl = $Config{perlpath}; $perl .= $Config{_exe} if $^O ne 'VMS' and $perl !~ /$Config{_exe}$/i; print "executable is $perl\n";

        (Completely off-topic: This is my 1000th post!)

        • another intruder with the mooring in the heart of the Perl

      kprasanna_79,

      I'm sorry, but did you even try it? Given how easy/fast it is to try what you're about to post, I'd highly suggest it - you seem to be very prone to confidently posting completely wrong information, which suggests to me that you need to find a new source of information. May I recommend the perl interpreter itself?

      $ uname -a HP-UX dessert B.11.11 U 9000/800 1131039648 unlimited-user license $ cat t.pl #! /usr/bin/perl print $^X,"\n"; $ ./t.pl /usr/bin/perl

      Name a platform where this works the way you say it does. I probably have access to it and will test it out. AIX (4 or 5), Sun (2.6 through 2.10), HP (11i, 11.23), HP/ia64 (11.23), Linux on ia32, ia64, amd64, ppc64, s390. Windows on ia32, ia64, or amd64 (although the latter two will take me a couple hours to get, I will call you on it). You pick. You even get to write the script if you want.

        You are both right. Under HP-UX it depends on the command used to start the script. If you start it with the full path, you will get the full path. If you start it with a relative value, you will get a relative value. That also goes for the shebang line.

        $ /usr/contrib/bin/perl -e 'print $^X, "\n"' /usr/contrib/bin/perl $ perl -e 'print $^X, "\n"' perl $ uname -a HP-UX noway B.11.00 A 9000/800 xxxxxxxx two-user license $ perl -e 'print $^O, "\n"' hpux

        --MidLifeXis

Re^3: path to perl interpreter
by Skeeve (Vicar) on Sep 29, 2005 at 10:14 UTC
    Just to add more information to it:
    $ perl whichperl.pl
    operating system: darwin
     executable: perl
    
    $ /usr/bin/perl whichperl.pl 
    operating system: darwin
     executable: /usr/bin/perl
    
    $ chmod +x whichperl.pl
    
    $ ./whichperl.pl 
    operating system: darwin
     executable: perl
    
    $
    

    $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://496006]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-09-23 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (219 votes), past polls