I'm trying to use a "package" subroutine to extract the filename of the calling script from the $0 variable. I pass the $0 variable to the subroutine, then parse it out using split. This works. Unfortunately, I can't figure out the correct syntax to pass that value back to the calling script. When I use return1, the subroutine will return to the calling program, but can't pass the $script[3] value back. Can anyone help me out?
package test_package;
sub subroutine1 {
@script = @_;
@script = split /\\/,$script[0];
}
return 1;
This is the code in the calling program:
require 'test_package.pl';
#
# call external subroutine!
test_package::subroutine1($0);
PETERV
Syracuse, NY &
Boston, MA
package test_package;
sub subroutine1 {
@script = @_;
@script = split /\\/,$script[0];
}
return 1;
This is the code in the calling program:
require 'test_package.pl';
#
# call external subroutine!
test_package::subroutine1($0);
PETERV
Syracuse, NY &
Boston, MA