PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

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 #
#                                                                          #
#==========================================================================#