in reply to Re^3: Perl linked list
in thread Perl linked list

Thanks for your explanation! So basically, it is just a data structure as hash of hashes or array of hash, right? Like in your example code, all scalar on the left are references. If I want to access the last element in the linked list, all I need to do is just keep deference it until the last one is reached, right? Something like $L->{'next'}->{'next'}->{'next'}->{'value'} right? ^_^

Replies are listed 'Best First'.
Re^5: Perl linked list
by Laurent_R (Canon) on Apr 01, 2015 at 07:23 UTC
    Yes, more or less, it is basically a collection of anonymous hashes, each or which contains a reference to the next element in the collection (except of course the terminator in which the reference to the next element is not defined). It could also be implemented as a bunch of arrays in which, for example, the first element would be the value and the seccond one the reference to the next array.

    Je suis Charlie.