On Tue, 8 May 2001, Adam Theo wrote:
> so, in short, any way i can get a subroutine to send *back* arguments
> to the piece of code that called it? all of this will be within the
> same program, i just am hoping there is a way to do this.
The last expression evaluated in a subroutine is returned, but you can
explicitly return a value by doing:
return $some_value;
If you have multiple values to return, put the return values into a list
context and grab it back that way:
sub some_sub {
#do stuff
return @vals;
}
my (val1, val2) = some_sub;
This is also a good way to return errors, failure of an algorithm (by
returning a false value, etc:
if(!some_sub()) {
# do something
}
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
... the flaw that makes perfection perfect.