Re: Simple multi-level tie

2004-01-07 Thread Martyn J. Pearce
On Tue, Jan 06, 2004 at 01:00:36PM -0600, david nicol wrote:
 that works too.  The first time I worked with dbm files, it was
 with an implementation that produced both a .pag and a .dir file
 for a database, so there was no one data file to lock.  If I just use
 Copendbm and let Perl select an implementation, I don't know what
 the file name is going to be.  It could be foo, it could be foo.db, it
 could be both foo.dir and foo.pag.  So if I use foo.advisory_lock for
 the advisotyr lock, I'm safe regardless of implementation.  I'm also
 safe from the implementation needing the flock bits if it uses them.
 I don't know that they do, but I also don't know that they don't.
 
 Also what would happen if you got your lockfile open syntax wrong
 and accidentally clobbered your data? 
 
 So I consider using a separate advisory file a best practice. I
 have never done a performance comparison, but owuld be curious to see
 one.

A splendid explanation.  Thanks for that.  Consider me convinced :-)

Mx.


Re: Date::Iterator, pollution, rating system, and how to make CPAN a better place [was: Re: RFC: Date::Iterator]

2004-01-07 Thread Marco Marongiu
Happy new year

A. Pagaltzis wrote:
If you're gonna go that route and put Day in the name but as a
separate namespace level, it should be Date::Calc::Iterator::Day
so there isn't a new 3rd level namespace for every date iterator
module with only one 4th level name in it.
I read all the comments, with this one last. I see your reasons.

If Steffen Beyer allows me to do so, I'll call the module 
Date::Calc::Iterator::Day, implement many of the proposed changes I had 
here and put it on CPAN.

Thanks to everybody for the time you took to discuss this module.

Ciao
Marco
--
Marco MarongiuEmail: [EMAIL PROTECTED]
System Administrator  Phone: +39 070 460 1684
Tiscali S.p.A.Fax:   +39 070 460 9684
International IT Services


New version of Roman available

2004-01-07 Thread Michel Rodriguez
Hi,

A while back I asked if it was possible for me to take over the
maintenance of Roman.pm.

I got no answer...

So anyway, a version with a Makefile.PL, tests and support for numbers
above 4000 is available at http://xmltwig.com/module/roman/

Is there anyway this version could end up on CPAn as the official
Roman.pm? At least it can be installed using the traditional
'perlMakefile.PL; make;make test; sudo make install;' incantation (note
that CPANPLUS install the current version properly).

--
Michel Rodriguez
Perl amp; XML
http://www.xmltwig.com





RFC: Data::Traverse

2004-01-07 Thread Michel Rodriguez
Hi,

I quite often have to deal with complex data structures, which structure I
have little info on. Typically this could be data created by XML::Simple,
from various XML files.

So I have written  a little module, Data::Traverse, that lets me either
extract data from a data structure (all scalars, or all references of a
certain type), or create iterators on the data structure.

Does this make sense? Is there something already available on CPAN that
would do just this (I looked in the Data namespace and did not see
anything)? Would it be worth releasing on CPAN?

An alpha version of the module is at
http://xmltwig.com/module/data-traverse/



SYNOPSIS
Data::Traverse supports 2 modes: a simple procedural interface and an
object-oriented interface.

  The procedural interface
The procedural interface can be used to retrieve parts of a complex
data structure.

It is used through use Data::Traverse qw(:lists)

  use Data::Traverse qw(:lists);

  my $data= ...;   # a complex data structure

  my @values= scalars( $data); # all scalars in the structure
  my @values= refs( $data, 'LWP::Simple'); # all LWP::Simple objects

  The OO interface
The OO interface is used to write iterators that go through a data
structure.

  my $iter= Data::Traverse-new( $data);
  $iter-traverse( sub { my( $iter, $item)= @_;
 print $item\n if( $iter-item_key eq 'id');
 return $iter-prune
   if( $iter-path_matches( '/foo/bar'));
   }
  );

  $iter-traverse( sub { $_[1]++ if( $_[0]-is_scalar); }); # changes the data

More methods are available to get information on the current context

DESCRIPTION
Data::Traverse lets you traverse complex data structures without
needing to know all about them.

It can be used for example with the data structure created by
XML::Simple

  Procedural Interface
refs ($data, $ref, $optional_level)
return the list of references of the $ref type (as per
UNIVERSAL::isa( $field, $ref)) in the data structure, in the
order of traversal (hashes are traversed through the dictionary
order of their keys).

The $optional_level argument can be used to limit the depth in the
data structure, 0 being $data itself.

scalars ($data, $optional_level)
return the list of scalar values in the data structure, in the
order of traversal (hashes are traversed through the dictionary
order of their keys).

The $optional_level argument can be used to limit the depth in the
data structure, 0 being $data itself..

refs_level ($data, $ref, $level)
return the list of references to $ref at $level in the data
structure.

scalars_level ($data, $level)
return the list of scalar values at $level in the data structure.

  Object-Oriented Interface
The Object-Oriented interface provides iterators on arbitrary data
structures. A handler is associated with the iterator and is called
for every item in the data structure. Within the handler a host of
methods can be called to get information about the current context.

new ($data)
create an iterator on $data

traverse ($handler)
traverse the data structure and apply the handler to all item of
the data structure. An item is anything in the data structure,
scalar, arrayref or hashref.

the handler is called with the iterator and the current item as
arguments. Use $_[1] if you want to update the original data
structure.

the handler also receives the item as $_

in the handler you can use the following functions:

path
the current path to an item in the data structure is built
from the hash keys to get to the item, joined with '/'.

path_matches ($exp)
$exp is a regular expression. The path is matched against that
regexp.

parent
the parent of the current item (a hashref or arrayref that
includes the item)

ancestors
the list (root first) of ancestors of the current item

item_index
if the item is an element of an array then this is the item
index in the array

item_key
if the item is a value in a hash then this is the item key in
the hash

parent_item_key
if the parent of the item is a value in a hash then this is
the associated key

data_level
the level of depth at which the item is found in the data
structure (the size of the ancestors stack)

path_level
the number of steps in the item path

is_scalar
return true if the item is a scalar (this is just !ref but
 

Re: New version of Roman available

2004-01-07 Thread Andy Lester
 A while back I asked if it was possible for me to take over the
 maintenance of Roman.pm.
 
 I got no answer...

Did you contact the original author?  Any response?

xoa

-- 
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance


Re: New version of Roman available

2004-01-07 Thread Michel Rodriguez
On Wed, 7 Jan 2004, Andy Lester wrote:

  A while back I asked if it was possible for me to take over the
  maintenance of Roman.pm.
 
  I got no answer...

 Did you contact the original author?  Any response?

Yes, I have tried several times in the last 3 years, with no result.

I might have found a more recent email address though, so I tried again
today.

--
Michel Rodriguez
Perl amp; XML
http://www.xmltwig.com




Re: New version of Roman available

2004-01-07 Thread Dave Rolsky
On Thu, 8 Jan 2004, Shlomi Fish wrote:

 Can't the CPAN administration team pass the ownership of the module to a
 different contender, in this case? Why do we need all these dead camels?

They can.  The procedure for this is documented at
http://www.cpan.org/misc/cpan-faq.html#How_maintain_module


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/