in reply to Re: Trying to slice off all array elements but the last one
in thread Trying to slice off all array elements but the last one

As usual, I'm dealing with a list of objects that came from a database. So I ask for one more than the number I really want so that I can tell if there are more to come. Before I actually display the items, I pop the last one off the list -- except in the case that this is the last page, in which case the last one is a real item.

Aside: I'm thinking about a different approach -- since I know what offset I'm at, how many objects I show on each page and how many objects are in the total list, I shouldn't have to fall back to 'getting an extra one' -- but that's a comment for another node. And I've also read (somewhere) about a module that takes care of all such list related functions, I jsut haven't used any of them yet. So many modules, so little time.

So, in my final implementation I actually took the array, popped off the extra one (if I wasn't on the last page) and did the search on that.

But as a somewhat experienced Perl dude, I should have remembered the $#array bit to provide me with the index of the last member of the array and been able to go from there. Sometimes stuff doesn't come loose when I shake my head. :( That's when I resort to Perl Monks. :)

Thanks for your response.

Alex / talexb / Toronto

Life is short: get busy!