[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [coldsync-hackers] p5-palm: problems looping through recordset and fields



thanks, very helpful. as you've correctly surmised, i am a newbie to perl. i
do have three more question before i wander through your primer though.

1.) i found good documenation for pack/unpack in the o'rielly programming
perl book (duh). i think i now get that it converts back and forth from
binary to string and that .pdb files are in binary format (please correct me
if i'm wrong). so if i want to do anything with the data, i have to run it
through unpack?


2.) what is the correct means of referencing a field once i've parsed it.

for example, below i have:

my $orgkey = $record[ORGK];

i found something similar in the cold-sync archives, but it doesn't seem to
work. what is the correct syntax?

3.) are there any significant differences in .pdb structure across palm os
versions. will this script work on older versions like that shipped with
PalmIII or Visor Delux.

sorry to ask such newbie stuff, but this is a growing edge for me. thanks
for all your help...gg


-----Original Message-----
From: owner-coldsync-hackers@lusars.net
[mailto:owner-coldsync-hackers@lusars.net]On Behalf Of Andrew
Arensburger
Sent: Thursday, April 08, 2004 11:30 PM
To: coldsync-hackers@lusars.net
Subject: Re: [coldsync-hackers] p5-palm: problems looping through
recordset and fields


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.


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.