in reply to caller of perl script

The simplest way is to get the bat file to pass %0% on the command-line to your perl script.

Getting the parent PID on Windows is not easy, but BrowserUk showed the way. To get the name of the bat file you need the Window Title, which is not included in the information returned from Win32::Process::Info. However, the tasklisk \V command does give it, the calling bat file is the final field (play with tasklist \V on cmd.exe if you are not familiar with the output). Here is my extension to BrowserUk's code:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Win32::Process::Info; my $pi = new Win32::Process::Info;; my @info = $pi->GetProcInfo( $$ ); my $ppid = $info[0]{ ParentProcessId }; # cdarke's addition from here # tasklist outputs a couple of lines of title junk first my ($tl_out) = (qx(tasklist /v /fi "PID eq $ppid"))[-1]; # The bat file name is the last "column" my $parent = (split /\s+/,$tl_out)[-1]; # $parent should now give the bat file name print "$parent\n";