in reply to finding perl58.dll

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.

Replies are listed 'Best First'.
Re^2: finding perl58.dll
by rvosa (Curate) on Aug 29, 2006 at 05:18 UTC
    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?
        But not to find the dll, I don't think? I thought M::SD only works on text files?
      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