Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem returning a value from a subroutine.

Status
Not open for further replies.

peterv6

Programmer
Sep 10, 2005
70
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top