In a message dated 4/6/2006 6:17:47 P.M. Eastern Standard Time, [EMAIL PROTECTED] writes:
 
> > From: "Conrad, Bill (ThomasTech)"
> > Subject: foreach question
> >
> > Give a foreach loop
> >
> > foreach $entry ( @list ) {
> >
> > }
> >
> > Is there a way to get the position index within @list $entry is from
> > without counting the iterations of the loop
>
> What I do when I need to know what element I'm dealing with is this:
>
> for ($i=0; $i<=$#list; $i++) {
>    # do something with $list[$i]
> }
>
> Hope this helps.
 
and then there's always:  
 
    my @array = something();
 
    for my $index (0 .. $#array) {
        do_something_with($array[$index]);  
        }
 
bill walters  
 
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to