Meaning of NEXT in Linked List creation in perl
- by seleniumnewbie
So I am trying to learn Linked Lists using Perl. I am reading "Mastering Algorithms with Perl" by Job Orwant.
In the book he explains how to create a linked list
I understand most of it, but I just simply fail to understand the command/index/key NEXT in the second last line of the code snippet.
$list=undef;
$tail=\$list;
foreach (1..5){
my $node = [undef, $_ * $_];
$$tail = $node;
$tail = \${$node->[NEXT]}; # The NEXT on this line?
}
What is he trying to do there?
Isn $node a scalar, which stores the address of the unnamed array. Also even if we are de-referencing $node, should we not refer to the individual elements by an index number example (0,1). If we do use "NEXT" as a key, is $node a reference to a hash?
I am very confused.
Something in plain English will be highly appreciated.