Home: Perl Programming Help: Frequently Asked Questions:
How do I handle circular lists?



Jasmine
Administrator

Jan 19, 2001, 3:13 PM


Views: 2757
How do I handle circular lists?

(From the Perl FAQ)

How do I handle circular lists?

Circular lists could be handled in the traditional fashion with linked lists, or you could just do something like this with an array:

Code
    unshift(@array, pop(@array));  # the last shall be first 
push(@array, shift(@array)); # and vice versa