|
|
sybperl-l Archive
Up Prev Next
From: rgates at lehman dot com (Robert Gates)
Subject: Re: Help! Alternate syntax for a foreach() loop
Date: Mar 6 1996 3:19AM
>
> On Mar 5, 1:55pm, Michael Sattler wrote:
> > Subject: Help! Alternate syntax for a foreach() loop
> > Michael's Sybperl examples provide something like this:
> >
> > >$ref = $d->sql("select * from foobar_table");
> > >
> > >foreach $line (@$ref) { print "@$line\n"; }
> >
> > Well, what if I want to reference the nth element instead of iterating
> > through all the results? I forget the syntax.
> >
> > Swift kicks gratefully accepted.
> >
>
If $array_ref is a reference to an array, you access the nth element with
$$array_ref[n]
.
HTH,
Robert
--
#==========================================================================#
# #
# Robert Gates Robert Gates #
# Production Support Fusion Systems Japan, K.K.#
# rgates@lehman.com bob@fsj.co.jp #
# #
#==========================================================================#
|