> sub foo {
>    my @this_array = ( "one", "two", "three" );
> 
>    bar ( @this_array );
> }
> 
> sub bar {
>    my @that_array = @_;
> }
> 
> So I'd pass a reference instead:
> 
> sub foo {
>    my @this_array = ( "one", "two", "three" );
> 
>    bar ( \@this_array );
> }
> 
> sub bar {
>    my $that_array = @_;

Problem. It should be 
        my ($that_array) = @_;          or
        my $that_array = $_[0];         or
        my $that_array = shift;

> 
>    foreach @$that_array {
>       # do stuff...
>    }
> }
> 
> Again, as I understand it the same applies to hashes
> as well but I'm more confused about hashes than I am
> about arrays.  How do I de-reference the
> hash-reference so that I can use it in my subroutine -
> similar to the @$that_array example used above (but
> for hashes instead).

sub foo 
{
        my %hash = ( key1 => 'val1', key2 => 'val2', key3 => 'val3' );
        bar (\%hash);
}
sub bar
{
        my $hash_ref = shift;
        for (keys (%$hash_ref)) {
                print "Value for key $_ is $hash_ref->{$_}\n";
        }
}       

> 
> Hopefully my question makes sense.  Thanks in advance
> of your help.
> 
> Jon Williams.
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

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

Reply via email to