On 26 May 2017 at 05:33, lee <[email protected]> wrote:
> Perl doesn't have data structures, so variables in perl are not data
> structures. That is unfortunate.
So when I write:
my $var = {
memory => {
total => 1024,
free => 100,
buffers => 10,
},
};
What do I have?
Because as far as I'm concerned, I have both data structures and
references in play.
References are not a low level mechanic that only the Perl VM needs to
care about.
References are a mechansim to allow data structures to be passed
*without copying*
my $x = 5;
my $y = $x; # x is a copy of y
However, if I do:
my $x = 5;
$y = \$x
Y is now a reference to X
If I now do:
${$y} = 10
X changes.
Its a useful tool, that programmers have uses for.
If you think they're evil, then you're probably thinking too much in C.
Because you can't do any real work in perl *without* references.
*Objects* in perl are blessed references.
Avoid that all you like, but you're just avoiding using Perl and
wondering why it hurts :)
--
Kent
KENTNL - https://metacpan.org/author/KENTNL
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/