hola to those at the monastary! i have a perl script, which is called by either a shell script or a bat file. i need to know the name of this calling shell/bat from within the called perl script. so, the obvious answer is "caller", but every variation i've tried does not get me the name of the shell/bat -- the highest up i can get is the name of the perl script. short of passing the name of the shell/bat to the perl script as an argument, is there anything that would yield the desired value?

follow-up -- thanks to everyone who responded, i applied a mixture of all suggestions. we have "call" scripts with are either shell (unix) or bat (windows), that call centralized perl scripts. there are about 100+ call scripts (asking 'why' is a moot point...that's just how it is), so modifying the call script to pass $0/%0% was an absolute last resort option (i'd prefer to change one perl script, rather than 101 shell/bat scripts.
sadly, i am in a VERY restricted environment, such that most of the suggested modules cannot be used (getting those modules installed takes an act of congress...almost literally). anyway...the code is below (obviously custom for my enviornemnts). it doesn't do properly if manually entering the name of the bat file at a windows command prompt, but the people executing the bat file will not be executing it that way.
thank you again for everyone who provided feedback to help me find a resolution.
sub _getppid() {
    my $ppid;
    my $name;

    if ($^O =~ /^MSWin32$/i) {
        my $pid = $$;
        my $machine = "\\\\.";
        
        require Win32::OLE;
        require Win32::OLE::Variant;
    
        # WMI Win32_Process class
        my $class = "winmgmts:{impersonationLevel=impersonate}$machine\\Root\\cimv2";
        if (my $wmi = Win32::OLE-> GetObject($class)) {
        	my $inc = 0;
        	while ($inc < 3) {
        		my $proc = $wmi->Get(qq{Win32_Process.Handle="$pid"});
        		if ($proc) {
    	            $ppid = $proc->{ParentProcessId} if ($proc->{ParentProcessId}!=0);
	                $name = $proc->{CommandLine} if ($proc->{ParentProcessId}!=0);
	                $pid = $ppid;
	                ++$inc;
        		}
            }
        }
        $name =~ s/cmd \/c ""(.*)" "/$1/;
    }
    else {
        $ppid = getppid();
		$name = `ps -o args -p $ppid`;
		chomp($name);
		$name = (split(/\n+/, $name))-1;
		$name =~ s/\/bin\/ksh (.*)/$1/;
    }
    
    return ($ppid, $name);
}

In reply to caller of perl script by red_draign

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.