Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl monks,
I'm trying to find the first element in a list using a foreach in order to do a different treatment:
foreach $element (@{my_list})what i want is something like:
foreach $element (@{my_list}) if ($element.fist) treat_1(); else treat_others();
Can anyone tell me how i can obtain the first element?
thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Determine first element in foreach
by MidLifeXis (Monsignor) on Aug 04, 2014 at 18:24 UTC | |
Re: Determine first element in foreach
by LanX (Saint) on Aug 04, 2014 at 18:06 UTC | |
Re: Determine first element in foreach
by frozenwithjoy (Priest) on Aug 04, 2014 at 18:34 UTC | |
Re: Determine first element in foreach
by neilwatson (Priest) on Aug 04, 2014 at 18:01 UTC | |
by tobyink (Canon) on Aug 04, 2014 at 20:12 UTC | |
by AnomalousMonk (Archbishop) on Aug 04, 2014 at 20:45 UTC | |
by tobyink (Canon) on Aug 05, 2014 at 07:17 UTC | |
Re: Determine first element in foreach
by 1s44c (Scribe) on Aug 04, 2014 at 21:36 UTC | |
by Anonymous Monk on Aug 05, 2014 at 08:17 UTC | |
Re: Determine first element in foreach
by runrig (Abbot) on Aug 04, 2014 at 21:25 UTC |