[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] find value in array



Does this "do stuff" to each element in the array that fits the test?

Bart Lateur wrote:

> On Sat, 14 Oct 2000 19:03:35 -0800, g3pb wrote:
>
> >is there a way other then using foreach to determie if an array contains a
> >particular value. in AppleScript it would be
> >
> >if list contains value then
> >    -- do stuff
> >end if
>
> grep(), or, if you need this test a lot, you should populate a hash.
>
>         if(grep { $_ eq $item } @list) {
>             print "List contains $item!\n";
>         }
>
>         @hash{@list} = ();
>         if(exists $hash{$item}) {
>             print "List contains $item!\n";
>         }
>
> --
>         Bart.
>
> # ===== Want to unsubscribe from this list?
> # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org

-- In Light and Love
EaTrom
Order of Melchizedek
Michael's Legions
----------------------------------------------------------------------------------------

EaTrom's Site:  http://www.blazing-trails.com Spirituality & Conspiracy
----------------------------------------------------------------------------------------


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org