Really simple question.
Jonathan Stowe
jns at gellyfish.com
Thu Feb 8 16:32:54 GMT 2007
On Thu, 2007-02-08 at 16:12 +0000, Andy Armstrong wrote:
> On 8 Feb 2007, at 15:35, Robert Bannocks wrote:
> > i.e. in
> >
> > foreach (@arrayname)
> > {
> > ...do some stuff..
> > }
> >
> > other than setting a count before the loop and incrementing it each
> > time how can I find out with in ...do some stuff...
> > how far through @arrayname I am?
>
> The normal idiom is
>
> for my $i ( 0 .. $#arrayname ) {
> # do some stuff
> }
>
Well the idiom for the paranoid is
for my $i ( $[ .. $#arrayname )
{
# do some stuff
}
but of course none of this actually answers the question - the answer is
actually "no": the provider of the list in the foreach could for
instance be a subroutine.
/J\
More information about the london.pm
mailing list