Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Dynamically Linked List

by chromatic (Archbishop)
on Jan 30, 2001 at 10:49 UTC ( [id://55201]=note: print w/replies, xml ) Need Help??


in reply to Dynamically Linked List

Perl allocates space automatically, as needed. You can do something like this:
my $tail; for (1 .. 10) { my %record = ( title => (1950 + $_), artist => 'chromatic orchestra', ); # handle first condition $tail ||= $record; $tail->{_prev} = \%record; $record{_next} = $tail; $tail = \%record; }
Untested, but that's generally one way to do it.

Update: Fastolfe pointed out that since I had changed my mind in the middle about the nature of %record, I should have changed the curly braces to parens. Fixed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found