Re: Looking up values in arrays?

2004-02-15 Thread Paul Johnson
On Sun, Feb 15, 2004 at 08:26:08PM +0100, Benjamin Walkenhorst wrote: > Is there a function to find out if a given value exists in an array? > > What I think of is something like &has_element([EMAIL PROTECTED], $value), which > should return either a boolean value or the index containing the valu

Re: Looking up values in arrays?

2004-02-15 Thread Benjamin Walkenhorst
Hello, On Sun, 15 Feb 2004 20:50:59 +0100 Paul Johnson <[EMAIL PROTECTED]> wrote: > > I'm sure something like this exists. Or do I need to write this > > myself? > > Something close exists. I think I'd probably code it as: Thanks a lot! =) Kind regards, Benjamin -- To unsubscribe, e-mail:

Re: Looking up values in arrays?

2004-02-15 Thread Wiggins d'Anconia
Benjamin Walkenhorst wrote: Hello everybody, Is there a function to find out if a given value exists in an array? What I think of is something like &has_element([EMAIL PROTECTED], $value), which should return either a boolean value or the index containing the value (undef if $value is not found)

Re: Looking up values in arrays?

2004-02-15 Thread Jan Eden
Hi, Benjamin Walkenhorst wrote: >Hello, > >On Sun, 15 Feb 2004 20:50:59 +0100 >Paul Johnson <[EMAIL PROTECTED]> wrote: > >> > I'm sure something like this exists. Or do I need to write this >> > myself? >> >> Something close exists. I think I'd probably code it as: > >Thanks a lot! =) > >Kind r

Re: Looking up values in arrays?

2004-02-15 Thread R. Joseph Newton
Wiggins d'Anconia wrote: > Benjamin Walkenhorst wrote: > > > Hello everybody, > > > > Is there a function to find out if a given value exists in an array? > > > > What I think of is something like &has_element([EMAIL PROTECTED], $value), which > > should return either a boolean value or the index

Re: Looking up values in arrays?

2004-02-16 Thread Rob Dixon
Paul Johnson wrote: > > > Is there a function to find out if a given value exists in an array? > > > > What I think of is something like &has_element([EMAIL PROTECTED], $value), which > > should return either a boolean value or the index containing the value > > (undef if $value is not found). > >

RE: Looking up values in arrays?

2004-02-16 Thread David le Blanc
use List::Util "first"; sub has_element($$) { my( $aref, $value ) = @_; first { $aref->[$_] eq $value } 0..$#$aref } ? -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Monday, 16 February 2004 10:57 PM To: [EMAIL PROTECTED] Subject: R