Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: How to implement Linked List

by Hofmator (Curate)
on Dec 18, 2006 at 12:42 UTC ( #590419=note: print w/ replies, xml ) Need Help??

in reply to How to implement Linked List

I must agree with rinceWind, I don't see the need for linked lists in your example.

For further reference, chapter 3 of Mastering Algorithms with Perl explains how to implement linked lists in Perl. The following code is an example out of the book:

#!/usr/bin/perl $list = $tail = undef; foreach (1..5) { my $node = [ undef, $_ * $_ ]; $list = undef; $tail = \$list; foreach (1..5) { my $node = [ undef, $_ * $_ ]; $$tail = $node; $tail = \$node->[NEXT]; } }

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Comment on Re: How to implement Linked List
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590419]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2015-10-07 12:34 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (184 votes), past polls