Hi Marija.
{} and [] create an empty anonymous array and hash, respectively. Their
value is a reference to the structure they have created. So:
$table = {}
Creates an empty hash and stores a reference to it in $table. Thereafter you
can access and manipulate it by:
$table->{key} = 'value'
etc.
After that you're getting a bit more obscure:
[$table]
creates a single-element anonymous array with the hash reference as its
single element. So:
somefunction([$table])
passes a reference to such an array to the function. Then somefunction would
be coded as something like:
sub somefunction
{
my $params = shift;
my $value = $params->[0]{key};
OR
my $table = $params->[0];
my $value = $table->{key};
print "$value\n";
}
Are you sure you /really/ want to do this? Or are you trying to understand
some existing code.
HTH,
Rob
----- Original Message -----
From: "Marija Silajev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 27, 2002 1:30 PM
Subject: References
> Hi,
>
> If you write something like :
>
> $table = {};
>
> is that hash reference? what do you actually initialize?
>
> and than:
>
> somefunction([$table])
>
> what is than [$table] ?
>
>
> Thanks,
> Marija
>
>
> --
> 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]