linked lists in perl?

abez abez at abez.ca
Thu Nov 7 00:16:19 CST 2002


Ok If I really had to do it this way I would use a structure like this:

$node = [$val,$arref]
$val would be a scalar, it could point or be anything
$arref would undefined or a listref.

Then to iterate you'd go

$node = $node->[1];

To add a new node you'd go

$node->[1] = [$val,undef];

Well that's how I'd do it.


On Wed, 6 Nov 2002, nkuipers wrote:

> Hello everyone,
> 
> I recently acquired one of those "Essentials" pocket books; this one is called 
> Data Structures I.  The chapter I am on right now deals with linked lists.  I 
> admit that the extent of my search for link-list-like structs in Perl has been 
> limited to scanning the index of the Camel 3rd (zilch), but does anyone know 
> how linked lists could be emulated in Perl, if at all (since as far as I know 
> Perl doesn't have anything like pointers...)?
> 
> Just curious.
> 
> Thanks,
> 
> Nathanael
> 

-- 
abez----- ----- ------ - ------ -- ------------
http://www.abez.ca/ Abram Hindle (abez at abez.ca)
--- --- ------ --------- - - ------ --------abez




More information about the Victoria-pm mailing list