On Sat, 30 Jun 2001, Steve Howard wrote:

> And (Since there are so many ways to do things in Perl) if you absolutely
> needed the index of the array as you were printing (like if something else
> was being done inside the loop besides a simple loop) you can still do it
> simpler than the C like loop you are using by doing a:
>
> foreach (0..scalar(@b)-1) {

Don't even need to be that verbose, since an array used here would be in a
scalar context anyway -- the scalar function is superfluous here.  But you
can also use $#b, which gives the index of th last element:

foreach (0..$#b) {

-- Brett
                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Senate, n.:
        A body of elderly gentlemen charged with high duties and misdemeanors.
                -- Ambrose Bierce

Reply via email to