Tom Allison wrote: > I want to keep a short list of the most recently used 'X'. > < 200 elements. > > Is there any suggestions other than to > unshift @recent, $element; > $#recent = $maximum; > > I know this will create a lot of array movement, but I can't think of > anything better off the top of my head. You? >
Now this is a situation that old farts like me ask our boss, "And what were you smoking when you thought this one up?" To translate into English, "What advantage does this give our users? Sure, we can do it but will it give our users a competitive edge or just distract them and waste their time?" Your solution will only work if $element is unique. Otherwise you will have multiple copies of $element on the list, and not the $maximum (unique) number of items. Try: @recent = grep { ! /^$element$/ } @recent; unshift @recent, $element; $#recent = $maximum; Notice how things became even slower? -- __END__ Just my 0.00000002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>