Try this, having put return $value at the end of sub_one

my ($numhits, @hits) = @_;
for (0 .. $numhits - 1) {
$returnedValue = &sub_one(&array_to_hash($_, @hits));}

-----Original Message-----
From: Birgit Kellner [mailto:[EMAIL PROTECTED]]
Sent: 09 August 2001 15:36
To: [EMAIL PROTECTED]
Subject: on returning subroutine arguments


I have a script that prints out database records after a search operation.
For each hit in the database, it calls the subroutine sub_one to first turn 
the record with the hit into a hash and then print out results in html. 
Now, there's one of these hash values which I would then like to use in a 
different sub, and I am wondering how to best go about it.

Here's the code so far:

##### main code #####################
my ($numhits, @hits) = @_; # @_ contains output from a different script
for (0 .. $numhits - 1) {
&sub_one(&array_to_hash($_, @hits));
}
########## end main code
####### begin subroutines
sub_one {
my %rec = @_;
print qq|<br>here is some code with $rec{'one'}, $rec{'two'}, 
$rec{'three'}.<br>|;
my $value = $rec{'three'};
}

sub_two {
my $value = $_[0];
&query($value);
}
########### end subroutines

I guess I could just call sub_two with $value as an argument from sub_one: 
&sub_two($value).

But is there a possibility to first return $value from sub_one to the main 
code and then do something with it there?
In other words, if I add "return $value" to sub_one, can I then use it in 
the main code like this:
########## main code #################
my ($numhits, @hits) = @_;
for (0 .. $numhits - 1) {
&sub_one(&array_to_hash($_, @hits));
my $value = $_[0]; # is $_[0] here the return argument from sub_one?
}
######## end main code

Birgit Kellner

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to