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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: dereference array of arrays from sql() in one statement.
Date: Jun 28 1999 2:21PM

kvk@hmco.com writes:
 > 
 > I'm just moving from Perl 4 to 5 and haven't quite figured out all the nuances
 > of deferencesing stuff yet.  Near as I can tell, the new sql() method returns
 > a reference to an array that contains a set of references to array thus presenting
 > a set of rows and columns without all that yucky split stuff from Perl 4.
 > 
 > Suppose I have just one row coming back and want get all the columns.  I've
 > coded the following which works just fine.  
 > 
 >    $cc = $db->sql($sql);        # do some SQL return one row
 >    $c = @$cc[0];		# get reference to array representing first row  
That should be
	$c = $cc->[0];
or
	$c = $$c[0];


@$cc[0] means an array slice (of length 1, starting at index 0) and
that is not what you want).

 >    ($col1, $col2, $col) = @$c;  # dereference array reference to get columns.
 >  

To get it all in one go:

	($col1, $col2, $col3) = @{$cc->[0]};


Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com