[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coldsync-hackers] p5-palm: problems looping through recordset and fields
- To: coldsync-hackers at lusars dot net
- Subject: Re: [coldsync-hackers] p5-palm: problems looping through recordset and fields
- From: Andrew Arensburger <arensb+CShackers at ooblick dot com>
- Date: Thu, 8 Apr 2004 23:30:07 -0400
- In-reply-to: <003401c41de1$138d7020$6501a8c0@CP001>
- Mail-followup-to: coldsync-hackers at lusars dot net
- References: <200404090233.i392Xn1W092986@shell.lusars.net> <003401c41de1$138d7020$6501a8c0@CP001>
- Reply-to: coldsync-hackers at lusars dot net
- Sender: owner-coldsync-hackers at lusars dot net
- User-agent: Mutt/1.4.1i
On Thu, Apr 08, 2004 at 11:16:39PM -0400, Greg Gard wrote:
> perl script (what i'd like to do, but doesn't really work):
>
> use strict;
> use Palm::Raw;
>
> ...(other misc code)...
>
> #LOOP THROUGH RECORDS
> my $questionid;
> my $qnum = 0;
> foreach $rs (@{$pdb->{records}}) {
> my @record = unpack("a", $rs->{data});
> my $orgkey = $record[ORGK];
^^^^^^
> my $surveykey = $record[SRVK];
^^^^^^
>
> #LOOP THROUGH FIELDS
> foreach $fld (@rs){
> $qnum++
> if ($record["Q" . $qnum] != ""){
^^^^^^^^^^^^^
> my $questionid($qnum) = $record["Q" . $qnum];
^^^^^^^^^^^^^
> }
> }
> }
You may want to read up on the difference between arrays and
hashes. Perl isn't PHP.
http://www.ooblick.com/text/perl/ might prove useful.
> i like unpacking to a single hash as opposed to a statement like:
>
> my ($var1, $var2, $var3) = unpack($unpackstr, $rs->{data});
>
> because i'd like to just loop through fields testing for null. also, i was
> unable to find any documentation on how to set $unpackstr (i found this in
> your mailing list archives). where can i find documentation about how to set
> unpack str.
How about TFM? Specifically, perlfunc(1). Look for "unpack".
--
Andrew Arensburger This message *does* represent the
arensb@ooblick.com views of ooblick.com
Cat rule #2: Bite the hand that won't feed you fast enough.
This message was sent through the coldsync-hackers mailing list. To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body. For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.