Brent Clark <mailto:[EMAIL PROTECTED]> wrote:
> Hi

Hi,
 
> Would someone please clear up / help me understand this.

Sure.
 
> I have a hash
> 
> my %allTariffData = {};

I think you meant  my %allTariffData = ();

> and in my sub
> 
> I have
> my %tariffData = {};

Same here.. my %tariffData = ();

>       do the processing etc
>       and then
> return \%tariffData;

A reference of %tariffData is returned to the caller.
 
> I now would like to use that data that in tariffData in another
> subroutine. 

I guess your initial subroutine would be like this.

$ref_tariffData = func();
subroutine func returns refernce to a hash.

If you want to use it in another subroutine. simply pass the reference
of that hash to the subroutine.
func2($ref_tariffData);

sub func2 {
        my ($ref_hash) = @_;
        foreach my $key ( keys %$ref_hash ){
                print "$key: $ref_hash->{$key}\n";
        }
}

> Would anyone be so kind as to share how I would go about this.
> 
> I can pass the whole hash, but that would not be right.

You can pass the whole hash but only if you are passing one hash. 
return %hash; # OK
return %hash1, %hash2; # May not be OK

Please read the following perldocs:

perldoc perldsc
perldoc perlref
perldoc perllol
perldoc perldata

It will make the things a lot clearer to you.

--Ankur

I don't suffer from insanity, I enjoy every minute of it!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to