Perl has built in fully dynamic data structures - arrays and hashes. These are in most cases sufficient for resident data needs. Can you explain why you need a linked list - is this a practical application or an academic exercise?
Here's something cobbled together - a class that will give you linked list:
package Data::LinkedList; sub new { my $pkg = shift; my %proto = @_; bless \%proto, $pkg; } sub data { my $self = shift; @_ ? ($self->{data} = shift) : $self->{data}; } sub next { my $self = shift; @_ ? ($self->{next} = shift) : $self->{next}; } 1; __END__ my $ele1 = Data::LinkedList->new( data => 'abel' ); my $ele2 = Data::LinkedList->new( data => 'baker', next => $ele1);
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)
In reply to Re: How to implement Linked List
by rinceWind
in thread How to implement Linked List
by msk_0984
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |