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

Re: Re[2]: [coldsync-hackers] Writing conduits that read more then oneDB.



On June 6, 2003 02:54 pm, Rob Bloodgood wrote:
> Friday, June 6, 2003, 12:17:34 PM, you wrote:
>
>
> IB> This is similar to my thinking, although I never thought of the
> possibility of IB> allowing users to specify just the DB name without the
> path.  If I take that IB> approach, then I could do something like this:
>
> IB> # Set default values
> IB> %HEADERS = (
> IB>         File            =>      "./TitraxTestOutput.txt"
> IB>         DBpath          =>      InputDB =~ /(.*)\/.*$/
> IB>         Datebookdb      =>      "DatebookDB.pdb"
> IB>         TitraxNoteDB    =>      "TitraxNoteDB.pdb"
> IB>         TitraxDataDB    =>      "TitraxDataDB.pdb"
>
> IB> );
>
> IB> Or not.  This produces a syntax error.  I'm guessing you can't set a
> hash IB> value like this, or am I doing it wrong?  Oh well, I'll just set
> DBpath from IB> within my dump function.  Unless there is a way to do what
> I'm trying here?
>
> You need commas after the values.
>
> The operator => is just a fancy comma, with the side affect that if
> what's to the the left of it is a valid identifier, it gets
> doublequoted. So, saying foo => "bar"  is the same as "foo", "bar"
> which gives you commas after your keys.  But you ALSO need commas
> after the values:
>
> %HEADERS = (
>         File            =>      "./TitraxTestOutput.txt",
>         DBpath          =>      InputDB =~ /(.*)\/.*$/,
>         Datebookdb      =>      "DatebookDB.pdb",
>         TitraxNoteDB    =>      "TitraxNoteDB.pdb",
>         TitraxDataDB    =>      "TitraxDataDB.pdb",
>
> );
>
> You'll notice a stray comma on the last one.  This is a non-error in
> perl, and convenient if you ever add more entries to the hash, because
> the comma is "already there" and prevents the syntax errors you saw.
>
> HTH!

Thanks Rob,

Sadly, it still doesn't work the way I'd hoped.  Part of the problem seems to 
be that InputDB =~ /(.*)\/.*$/ doesn't actually return a scalar.  It works 
when I print, but attempts to assign the result to a scaler returns a number 
(the number of matches I believe).  It seems to do what I want, I'd need to 
do something like:

( $HEADERS{ DBpath } = $HEADERS{ InputDB }  ) =~  !(.*)/.*$!$1!;

Which does have the desired effect but isn't usable above.  If I use it in a 
function after the headers have been processed, then I'd want to test that 
DBpath didn't have a valid entry first.  Something like this:

if !defined $HEADERS{ DBpath } 
	{
	( $HEADERS{ DBpath } = $HEADERS{ InputDB }  ) =~  !(.*)/.*$!$1!;
	}

This is what I'm doing now.  I'd still like to be able to load it as a default 
value in the hash above before the headers are processed though.  If anyone 
has suggestions of how this could be done, I'd love to here them! ;)

I'm sure there are other places my code could be improved as well.  I'm 
currently working on parsing the data from the TitraxNotesDB.  I already have 
it reading the data out of the DatebookDB.  At this point, I'm really just 
extracting the data and dumping it to a text file.  Once I'm done I could 
post what I have here for some feedback.  If that's OK with Andrew that is.  

Once it's finished and does something useful (I'm thinking formated text 
output, HTML output, and SQL output), I'll make it available as a package for 
anyone interested.  My specific interests are with the SQL output.  I'm 
planning on building a weblet for displaying and modifying the data from the 
database.

...Izzy

-- 
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.