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

[coldsync-hackers] Thanks Christophe...



After replying to your post I came up with the following solution which merges 
your suggestion with what I was already doing.  This still provides the 
flexability of allowing the user to specify names and paths for each of the 
databases, or just the path to where they can be found.  The foreach loop 
saves on a lot of code.  A much more elegant solution! ;)  Thanks.

# Set default values
%HEADERS = (
    File            =>  "./TitraxTestOutput.txt",
    Datebookdb      =>  "DatebookDB.pdb",
    TitraxNoteDB    =>  "TitraxNoteDB.pdb",
    TitraxDataDB    =>  "TitraxDataDB.pdb",
    Target          =>  "Text",
);

my %pdbs;

if (!defined $HEADERS{ DBpath } )
	{
	( $HEADERS{ DBpath } = $HEADERS{ InputDB } ) =~ s!(.*)/.*$!$1!;
	}
foreach( qw(Datebookdb TitraxNoteDB TitraxDataDB TitraxNameDB) )
	{
 	($pdbs{$_} = $PDB and next) if $PDB->{name} eq $_;
  	unless ( $HEADERS{ @_ } =~ /^\// )
   		{
		$HEADERS{ @_ } = join( "/", $HEADERS{ DBpath },
  			$HEADERS{ @_ } );
		}
	$pdbs{$_} = new Palm::PDB;
	$pdbs{$_}->Load(  $HEADER{$_} );
 	}

I haven't tested the code yet, so there may be bugs...

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