use strict; use warnings; use Win32::API; Win32::API->Import('kernel32.dll', 'DWORD GetCurrentProcessId()') or die "Can't import GetCurrentProcessId: $^E\n"; my $procid = GetCurrentProcessId(); if (defined $procid) { print "Returned '$procid'\n"; } else { print "Returned \n"; }