Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

finding perl58.dll

by rvosa (Curate)
on Aug 29, 2006 at 04:10 UTC ( #570085=perlquestion: print w/ replies, xml ) Need Help??
rvosa has asked for the wisdom of the Perl Monks concerning the following question:

Is there a portable way to figure out, from within a script, where the perl58.dll (or however it's called on various platforms) associated with the $^X that is running the script is located?

Comment on finding perl58.dll
Re: finding perl58.dll
by GrandFather (Cardinal) on Aug 29, 2006 at 04:24 UTC

    I'd guess perl58.dll is pretty specific to an ActiveState installation so using the same path as given by $^X is likely to be safe.

    Note that the related type library and header are in '../lib/CORE/' with respect to the folder containing perl.exe (or wperl.exe).


    DWIM is Perl's answer to Gödel
      I'd guess perl58.dll is pretty specific to an ActiveState installation

      It's pretty specific to a Win32 installation.

      That said, it needs to be in the directory of the .exe that uses it or in the $ENV{PATH}, so I'd imagine it can also be found heuristically in most cases.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: finding perl58.dll
by BrowserUk (Pope) on Aug 29, 2006 at 04:34 UTC

    This will do it on Win32:

    #! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'kernel32', q[ HMODULE GetModuleHandle( char *lpModuleName ) ] ); ApiLink( 'kernel32', q[ DWORD GetModuleFileName( HMODULE hModule, LPTSTR lpFilename, DWORD + nSize ) ] ); my $name = chr(0) x 256;; GetModuleFileName( GetModuleHandle( 'perl58.dll' ), $name, 256 ); print $name; __END__ c:\test>570085 c:\perl\bin\perl58.dll

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks for those replies! I was a bit unclear in my initial post, I think, though. I was wondering if there is a more general way to figure out where the $Config{libperl} lives that the running perl interpreter needs/is using. For example, how does PAR figure that out?
        I was wondering if there is a more general way to figure out where the $Config{libperl} lives

        I think the following would always produce the correct path on Win32 to $Config{libperl}:

        perl -MConfig -e "print $Config::Config{archlib}.'\\CORE\\'.$Config::Config{libperl}"

        Works for me - and on Linux if rewritten (with corrections to the directory path separator) as:

        perl -MConfig -e 'print $Config::Config{archlib}."/CORE/".$Config::Config{libperl}'

        Attend to the path separator issue (if that's applicable to your needs) and you should be able to come up with a truly portable script.

        Cheers,
        Rob

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-10-24 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls