J
Jürgen Herz
Hi,
currently I'm trying to understand references. I've read perltut.pod and
perlreftut.pod but still don't know why does this works:
my $content = test();
for (keys %{$content})
{ print "$_: ",$content->{$_},"\n" }
sub test
{
my %content = (one => "eins", two => "zwei");
return \%content;
}
I'd expect accessing the hash in main doesn't work because it doesn't
exist anymore outside of test(), just the pointer to that gone hash.
I guess I'm wrong in understanding references as pointers like they are
in C. But what are they then?
Regards,
Jürgen
currently I'm trying to understand references. I've read perltut.pod and
perlreftut.pod but still don't know why does this works:
my $content = test();
for (keys %{$content})
{ print "$_: ",$content->{$_},"\n" }
sub test
{
my %content = (one => "eins", two => "zwei");
return \%content;
}
I'd expect accessing the hash in main doesn't work because it doesn't
exist anymore outside of test(), just the pointer to that gone hash.
I guess I'm wrong in understanding references as pointers like they are
in C. But what are they then?
Regards,
Jürgen