use Win32::API (); sub GetPerlExePath { my $f= 'GetModuleFileName'; my $m= Win32::API->new( 'kernel32', $f, 'III', 'I' ) or die "Can't find $f() in kernel32.dll: $^E\n"; my $l= 512; my $s= ' ' x $l; my $a= unpack "I", pack "P", $s; my $r= $m->Call( 0, $a, $l ); die "$f failed: $^E\n" if ! $r; $s= substr( $s, 0, $r ); return $s; }