richill has asked for the wisdom of the Perl Monks concerning the following question:
I'm almost embarassed to ask this because Im sure the answer is no, but is it possible to have a foreach loop loop through and array and return 2 values of the array in the same call.
I'll try to explain it better,
the xxxx would be some code that makes this function return@names = ('rita', 'sue','bob', 'daisy') foreach $name (@names){ print "$name xxxxx \n"; }
rita sue sue bob bob daisy daisy
If not, what is the best way of doing this? Im leaning towards using a forloop and the array in a scalar context.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: foreach loops
by Arunbear (Prior) on Oct 07, 2006 at 22:30 UTC | |
by johngg (Canon) on Oct 07, 2006 at 23:25 UTC | |
by richill (Monk) on Oct 08, 2006 at 07:57 UTC | |
by lyklev (Pilgrim) on Oct 08, 2006 at 12:28 UTC | |
by shmem (Chancellor) on Oct 08, 2006 at 12:42 UTC | |
Re: foreach loops
by Corion (Patriarch) on Oct 07, 2006 at 21:58 UTC | |
Re: foreach loops
by shenme (Priest) on Oct 07, 2006 at 21:57 UTC | |
Re: foreach loops
by zentara (Archbishop) on Oct 08, 2006 at 13:00 UTC | |
Re: foreach loops
by dokkeldepper (Friar) on Oct 08, 2006 at 10:38 UTC | |
Re: foreach loops
by pbeckingham (Parson) on Oct 08, 2006 at 13:19 UTC | |
Re: foreach loops
by jwkrahn (Abbot) on Oct 09, 2006 at 00:15 UTC |
Back to
Seekers of Perl Wisdom