in reply to code sample: possible improvements

No, you have not created a linked list. You've created a single-element hash, holding a reference to an element of an array named @data. The element being referenced is $data[2].

So to answer your question, no, that is not a linked list. As for how you can change it? I don't know.... what do you have in mind? I mean change it in what way? What kind of change are you after? Do you need it to be a linked list? If so, will there be additional elements, and how are you adding them, etc?

Basically, I guess in order to help you more, you're going to have to go ahead and give us some idea of what it is you want to do so we dont' have to guess.


Dave

Replies are listed 'Best First'.
Re^2: code sample: possible improvements
by arcnon (Monk) on Jan 10, 2005 at 03:57 UTC
    I was told it was a linked list.... I didnt think it was. So I thought I would ask here. I just know I dont know everything : )

      Well, there's no list there. A basic linked list is a list where one element contains data, as well as a pointer to the next element. The next element contains data, and a pointer to the next element, and so on.

      If you're really interested in linked lists, most textbooks on Computer Science discuss them at one point or another. If you're interested in implementing a linked list in Perl, I recommend the book, Mastering Algorithms with Perl (the Wolf book), published by O'Reilly & Associates. It has a chapter devoted to linked lists, and gives a pretty good discussion of other types of complex datastructures too. It's not really a beginning Perl book. If basic Perl is what you're looking for, start with reading Perl's own POD. For example, perlreftut, and perldsc discuss datastructures and references. But if you're kind of beyond that level and ready for more then try the algorithms book, it's pretty interesting.


      Dave