I have the following code, in which I have a structure ($node) that is a scalar by declaration, but seems to be a hash by usage:
sub LoadData()
{
#not significant code here
my $node = {
BaseName => "deviceA",
SysDescr => "Example device",
SysObjectId => "SysObjectIdTest",
ManagementIpAddress => "BLABLABLA",
Protocol => "1",
};
$store->AddDeviceData( 1, $node->{BaseName}, $node );
}
My question is: that $node, declared as we see above, is an hash or a scalar? I mean, is there a difference (in terms of beahvior) between
my $hash = {
#some foo => "bar" assign here
};
and
my %hash = (
#some foo => "bar" assign here
);
and
my %hash = {
#some foo => "bar" assign here
}
PS: it behaves as an hash reference because AddDeviceData() restricts the last argument to be an hash reference.
PSS: Maybe it had something related to context; an hash being assigned to a scalar means assigning a reference to the hash and not the content of the hash itself, but I´m not pretty sure.