pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gene Selkov, Jr. <joden@lee.k12.nc.us>
To: James Olin Oden <joden@lee.k12.nc.us>
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Perl Interface
Date: Tue, 22 Jun 1999 23:31:38 -0400
Message-ID: <199906230428.XAA01514@antares.mcs.anl.gov> (raw)
In-Reply-To: <376FF3EF.C450B29B@lee.k12.nc.us>

Sorry I did not catch up with the original question; I believe things
you discuss here are better answered by reading "man perldata" or "man
perlref". But let me make a few comments, anyway.

> Looks like you caught my "|" error (-;  Seriously, I though the
> following should do it:
> 
>       while (@row = $result->fetchrow) {
>             $string = join("\|",@row);
>             push @set, ($string);
>       }
> 
> If though you wanted to put them in a multidimensional array (well
> really a list of references to lists then you would do something like:
> 
>       while (@row = $result->fetchrow) {
>             push @set, (@row);
>       }

{push @set, ($string)} is the same as {push @set, $string} or {push (@set, $string)}

{push @set, (@row); is the same as {push @set, @row} or {push @set, $row[0], $row[1], ...}

 
There is no such thing as multidimensional array in perl. 

One can simulate multidimensional arrays by using arrays of
references. You probably wanted to say,

push @set, [@row];

or

push @set, \@row;


> 
> and then you would reference each element like this:
> 
>    $set[$i][$j]
> 
> or:
> 
>    $set[$i]->[$j]
> 
> depending on your mood.


which would now now be true.

--Gene



view thread (17+ messages)  latest in thread

Message-ID: <199906230428.XAA01514@antares.mcs.anl.gov>
Permalink:  ../199906230428.XAA01514@antares.mcs.anl.gov/
Also on:    postgresql.org/message-id/199906230428.XAA01514@antares.mcs.anl.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: joden@lee.k12.nc.us
  Subject: Re: [INTERFACES] Perl Interface
  In-Reply-To: <199906230428.XAA01514@antares.mcs.anl.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox