RE: easy way to add element to array
From: Bob Showalter (Bob_Showalter_at_taylorwhite.com)
Date: 10/29/04
- Next message: Thomas Bätzler: "Re: Newbie: Perl Vs Shell"
- Previous message: Bob Showalter: "RE: each character in a string"
- Maybe in reply to: Brian Barto: "easy way to add element to array"
- Next in thread: Jeff 'japhy' Pinyan: "RE: easy way to add element to array"
- Reply: Jeff 'japhy' Pinyan: "RE: easy way to add element to array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "'brian.barto@spectrum-health.org'" <brian.barto@spectrum-health.org>, beginners@perl.org Date: Fri, 29 Oct 2004 15:10:56 -0400
brian.barto@spectrum-health.org wrote:
> Though about using a hash but I don't have a need for a Key/Value
> combination. I just need a list without duplicates. I suppose I can
> define the hash keys if they don't already exists and export the keys
> into an array with the keys function. Is that what you are hinting
> towards?
Yes, that's what I'm hinting at :~)
A hash would be called for if you need to do repeated tests to see whether
an element exists in the set. The downside to pulling the unique values with
keys() is that you lose the original order, if that matters.
Tie::Array::Unique will take care of the problem and preserve the order,
while letting you push entries onto the array without worrying about
creating duplicates.
- Next message: Thomas Bätzler: "Re: Newbie: Perl Vs Shell"
- Previous message: Bob Showalter: "RE: each character in a string"
- Maybe in reply to: Brian Barto: "easy way to add element to array"
- Next in thread: Jeff 'japhy' Pinyan: "RE: easy way to add element to array"
- Reply: Jeff 'japhy' Pinyan: "RE: easy way to add element to array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|