I’m a database guy, but Perl is new to me. I have a script called
ServiceScript.pl that contains a subroutine called ServiceRoutine.
This routine connects to a database and returns data into an array. I
want my customer to be able to call this subroutine from any of their
hundreds of perl scripts, so I’m telling them to put this kind of code
into a script if it needs data from the database:

require 'ServiceScript.pl';
my $eascmdline = "$uspname $uspparams";
$rtncode = ServiceRoutine($svccmdline, \...@rtndata);

My script passes the requested stored procedure name and parameters to
the database, then returns data in the @rtndata array. It also uses
the “caller” statement to determine what perl script is calling it,
and records that information in the database for auditing purposes.

My question is this – how can my ServiceRoutine in ServiceScript.pl
get its own path? I would like to record this to the database for
auditing purposes as well, to make sure no one is using a substitute
version of ServiceRoutine from another script.

If I use $0 in ServiceRoutine, and if CallTheService.pl calls it, $0
in ServiceRoutine returns “CallTheService.pl”, instead of
“ServiceScript.pl” which is what I want to see.

If I use getcwd() in ServiceRoutine, once again it returns the current
working directory of CallTheService.pl, not ServiceScript.pl’s
directory.

How can my subroutine report its own path, and not the path of the
script that is calling it?
- Marko


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to