What is the difference between setting a hash like this:
and like this:
Apparently each statement is setting an entirely different hash.
Which is the proper way to do it?
And also if I were to concatenate the hash with a string using double quotes how would i do it?
I tried:
But perl does not interpret the "->" symbol.
I tried this:
which works but how do I get perl to interpret the "->" symbol?
Code:
$fooref->bar('cat');
and like this:
Code:
$fooref->{bar} = 'dog';
Apparently each statement is setting an entirely different hash.
Which is the proper way to do it?
And also if I were to concatenate the hash with a string using double quotes how would i do it?
I tried:
Code:
print "This is a $foo->bar";
But perl does not interpret the "->" symbol.
I tried this:
Code:
print "This is a $$foo{bar}";
Code:
use Class::Struct;
struct foo =>
{
bar => '$'
};
my $fooref = foo->new();
$fooref->bar('cat');
$fooref->{bar} = 'dog';
print $fooref->bar;
print "\n";
print $fooref->{bar};