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: "Chris Jack" <jackc at rabo-bank dot com>
Subject: RE: Why the brackets ()
Date: Mar 16 1999 11:16AM

The () are saying to treat the contents (i.e. $database and any other 
elements you might have specified) as a list so $database gets allocated 
the 0th element from the list pointed to by the reference $row. If you 
don't have the brackets, the @$row gets treated as a scalar and $database 
will be allocated the number of elements in that list (probably 1 in your 
case). If you were selecting more than one column, this might be more 
obvious.

Chrisj

-----Original Message-----
From:	Andrew J Davies [SMTP:Andrew.J.Davies@aib.ie]
Sent:	Monday, March 15, 1999 4:45 PM
To:	SybPerl Discussion List
Subject:	Why the brackets ()

Hi
Why, when I remove the () from around the $database variable do I get an
error.
What are the () actually doing. Without  them $database == 1
                    With them ($database) == "a valid database name"


@rows = $dbh->ct_sql("select name from sysdatabases where name like
\"$opt_D\"");

foreach $row (@rows)
{
     ($database) = @$row;                # ????????????
     next if ( $database eq "master" || $database eq "model" || $database
eq "sybsystemprocs" );
     print "$database.\n";
     ...

}


Thanks for your time.
Andy