Hi,


What I am trying to do is just to understand better why do I get an error message.
Actually I use Net::Netmask module, and there I simply just do as the README file says.


$block =new Net::Netmask ($network_block);

$table = {};

$block -> storeNetblock([$table]);

and than comes an error:

No such pseudo-hash field "3758096384" at /usr/lib/perl5/site_perl/5.6.1/Net/Netmask.pm line 222, <> line 23.

Although it is more clear what is going on it doesn't help me to understand where is the mistake.


Any idea?

Thanks anyway,
Marija






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]

Reply via email to