develooper Front page | perl.perl5.porters | Postings from March 2013

Re: Is there a module that provides an abstract record class?

Thread Previous | Thread Next
From:
Sébastien Aperghis-Tramoni
Date:
March 29, 2013 13:55
Subject:
Re: Is there a module that provides an abstract record class?
Message ID:
44907308.10783167.1364565292945.JavaMail.root@spooler3-g27.priv.proxad.net
Tom Christiansen wrote:

> Hey guys,
> 
> My CPAN search-fu seems to be flagging, because I cannot find
> something that surely must exist, and it seems a shame to 
> re-implement a perfectly functioning wheel if it already exists
> and I just don't know about it.
> 
> I wondered whether you knew of a somewhat generic, plug-in-able
> frameworky class that allows you to read structured records from
> files of various formats in a uniform fashion, and treat those
> records the same way using some common interface.  I'm betting
> it must already exist, but I could find nothing on CPAN that
> seemed at all like what I am thinking of.

From what you described, I don't know something that versatile and
pluggable. For text files, Augeas might be a solution for you. It's
based on the theory of lenses, to accurately edit structured files.
A lens describes the format in something vaguely looking like CAML
(or so I've heard; I only know I didn't find it easy to write lenses).
You then open files by specifying the format and you can read, edit
and write them, always preserving their inner structure; accessing
the fields via something similar to XPath.
  » http://augeas.net/

Their is a Perl binding, Config::Augeas
  » https://metacpan.org/module/Config::Augeas

It's obviously very oriented for sysadmin tasks, but the engine and
lenses can handle most kinds of structured text files. "Most" because
the grammar engine is limited, although it has greatly improved over
the years to handle, for example, Apache config format.


-- 
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About