Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Create two-dimensional Array from string

Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!news.albasani.net!not-for-mail
From: Ted Zlatanov <t...@lifelogs.com>
Newsgroups: comp.lang.perl.misc
Subject: Re: Create two-dimensional Array from string
Date: Tue, 08 Apr 2008 11:04:28 -0500
Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @
 Cienfuegos
Lines: 30
Message-ID: <863apw9vub.fsf@lifelogs.com>
References: <084df03f-a367-4aba-ba8b-4841e6315499@8g2000hsu.googlegroups.com>
	<3d7e68ac-9446-4921-9008-83bbfbe60a51@a23g2000hsc.googlegroups.com>
	<287d4280-d4b0-4e37-a7f7-2f138280b382@m3g2000hsc.googlegroups.com>
	<86od8pd3d9.fsf@lifelogs.com>
	<08af09af-6108-4539-9fa5-956876a8a7ee@b64g2000hsa.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.albasani.net TddQkja9aQZeXHSWbE9mPDUtYl9s3QqiWw8i6R32XeW5pi4Cn5+Lpc/zDvlxT2FLs9vnefPycZY6K2V0pskG3Lt/eHLSTTB2oeUmXUMFniqryluZvZEf5hARgbtnHb9b
X-Complaints-To: abuse@albasani.net
NNTP-Posting-Date: Tue, 8 Apr 2008 16:01:40 +0000 (UTC)
X-User-ID: a0Vkgmv1Xf2v4NzRHRnOXBCEzOomjZGz0IZmczj70Rc=
X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx"
Cancel-Lock: sha1:YGNEyDl4HNBCQo0u/vg4oT50cus= sha1:JBrOPO3/w8/sI8FroyIl8aDFeBY=
User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux)
X-NNTP-Posting-Host: 3VJ6mnq+AS2j1dWfEVMFJnHFV232lcsie0mSjrv7L2c=

On Mon, 7 Apr 2008 06:50:46 -0700 (PDT) "pjfa...@gmail.com" <pjfa...@gmail.com> wrote: 

pc> I went ahead and tried selectall_arrayref and as I thought it did no
pc> better than it's cousin fetchall_arrayref.
pc> The problem is a MULTISET returned by DBI/DBD as a varchar and the
pc> driver doesn't know how to parse
pc> it into an array.  There are 2 solutions to this 1) separate the
pc> mutliset into a separate query and loop through original cursor.  or
pc> 2) manipulate the varchar into an array like above with the eval or
pc> use 's//g' and splits to manipulate
pc> into a array.  Luckily MULTISETs are pretty reliable in what they
pc> return so the eval approach works great.  And it's
pc> performance problems are better than network latency by looping.

pc> Thank you for your suggestion got me to look at selectall_arrayref,
pc> I've had a habit of using fetchall_arrayref
pc> but will use selectall_arrayref more in the future.

Well, I owe you an apology because I thought MULTISETs were parseable by
the DBI.  So you do need a custom parser or to split the results up.
Maybe a temporary table would work best for you if there are only a few
results (but you'll have to have an extra field to distinguish between
multiple instances of the same query, and it gets ugly quickly).

I've posted in the past here about the dangers of evaluating data,
especially data you don't control.  So the eval-based parser worried me
(and others who have responded).  I would use a regular expression as
you mentioned, if possible, or write a more complex state-based parser.

Ted