Re: AnyData::Format::Ini and dhcpd.conf

From: Jeff Zucker (jeff_at_vpservices.com)
Date: 05/14/04


Date: Fri, 14 May 2004 09:13:59 -0700
To:  egan@sense.net, dbi-users <dbi-users@perl.org>

Egan Ford wrote:

> "This is a parser for simple name=value style Ini files. Soon it will also
> handle files with sections."
>
> Is there an update?

I'm attaching a couple of things I've got sitting around but that aren't
ready for release yet that might help you. The first works like this:

   my $dbh = DBI->connect('dbi:AnyData(RaiseError=1):');
   my $AoH = [ { id=>1,phrase=>'foo' }
             , { id=>2,phrase=>'bar' }
             ];
   $dbh->ad_import('t','Hash',$AoH);
   print "ok!" if 'foo' eq $dbh->selectrow_array("
       SELECT phrase FROM t WHERE id=1
   ");

With some modification, it could automatically read a text file, use
eval to turn it into a hash and import it, then on export use
Data::Dumper to print it back to file.

The second attachment should parse and import Ini files with sections
and even preserve comments within the Ini files.

Neither is ready for prime time. If you (or anyone else) wants to take
on authorship of these, please do!

> I am looking to maintain a dhcpd.conf type format with DBI.

It looks to me like dhcpd.conf format can include an unknown level of
nesting so it's not a good candidate for importing into strict database
table format. Also, it looks rather hairy, have those guys heard of
YAML? :-) But if all you need to do is parse a subset of dhcpd rather
than the whole syntax, my suggestions may help. Also if there's a dhcpd
parser out there, it would be simple to write an AnyData::Format plugin
that used the parser. If that's a direction you want to go and you need
hints, let me know.

-- 
Jeff


Relevant Pages

  • Re: Sending a Fax with Outlook 2002
    ... Your English is fine. ... i tried do it with and without attaching a word file. ... >>State the format of the message you are trying to send. ...
    (microsoft.public.outlook.fax)
  • RE: Help! HDD probs
    ... You can try attaching this to another PC and tansfer dsata if it is ... I would also suggest that any attempt to format the drive will not proceed ... Do not format the drive if you want the maximum recovery of data. ... after restart it wants to format! ...
    (microsoft.public.windowsxp.hardware)
  • Re: many sheets from "master data"
    ... I am attaching the rawdata compressed document, that is fixed column, ... no other format (if you open it, the format will be all over the place, ...
    (microsoft.public.excel.misc)
  • Re: hfs+ and ufs
    ... nodes after loading geom_apple.ko and attaching the usb drive, ... If I format the partition on freebsd as UFS1, ...
    (comp.unix.bsd.freebsd.misc)