Friends,

I would appreciate if you can throw light more on the subteleties of the
following two questions:I have this code and comments for the ease of
understanding my questions:

#========================================================
#!/usr/bin/perl
use strict;
#       IF I do not assign {}, nothing is printed
my($hash) = {}; 
&getArray($hash);

#       IF I do not engulf array-ref within {} as @{$hash->{array}}
#       an error message NOT AN ARRAY reference is generated
map {print "$_\n"} @{$hash->{array}}; 

sub getArray{
        my($hash)       = shift;
        $hash->{array}  = [1,2,3,4,5];
}
#========================================================


a) When a hash reference is essentially a SCALAR, why should I explicitly
denote the hash variable as
        my($hash)       = {};
and not simply
        my($hash);

b) I thought that an array can be dereferenced simply by @$arrayRef
notation. However, in the code sample I have sent, I am forced to use
@{$arrayRef} notation. Why do I need the Chain-braces?

Please clarify,
Thanks,
Rex 

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

Reply via email to