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
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:
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)
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
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
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).
> >
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