in reply to Re: Getting element of array with a match
in thread Getting element of array with a match

A variation on the theme of grep
my @ar = map { chomp; $_ } <DATA>; print +(split /,/, $ar[ grep { /^(\d+)/ and $1 < 1006 } @ar ])[1], $/; __DATA__ 1001,choochoo 1002,candycane 1003,sockpuppet 1004,choochoo 1005,candycane 1006,sockpuppet6 1007,foo 1008,bar
This of course blindly assumes that you're data is a linear, contiguous set of numbers.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Re: Getting element of array with a match
by peppiv (Curate) on Dec 23, 2002 at 16:04 UTC
    Thank you everyone for the help and education. I got what I needed and everything works perfectly!

    peppiv