SPUG: Ordered Hash Tie Class

Chris Wilkes cwilkes-spug at ladro.com
Tue Apr 6 12:34:48 CDT 2004

On Tue, Apr 06, 2004 at 10:03:13AM -0700, Ingmar Ellenberger wrote:
> I need it to be able to handle multiple values for a given key and have
> handlers to deal with them.
> What I'm REALLY trying to do is create tools to manipulate Java property
> files while while maintaining comments and whitespace.

Can you have multiple values for a single key in java property files?
Most of mine look like this:
   # this is a comment
   # remote directory

   # username for scp

as for whitespace, I haven't seen that in use either, but I would
imagine its done like this:
   message="I'm in the Dilbert Zone"

I take it eventually you want to get to something like this:
  $prop = My::JavaProperty->new("clothingreport.properties");
  @keys = $prop->getKeys();
  $columns = $prop->get("columns");
  $prop->set("columns", $columns);
it might be handy to have a method ->getComment() to get the comment
lines above a certain key.  Course then you would have to stipulate that
one seperates keys with whitespaces.

What I would do is slurp everything into an array (as property files are
never that long) and then when someone requests a key, just go through
the array looking for it, keeping track of its position in the array.
Then when they change it, just change that position's value.

And I could of saved myself a lot of time by looking on CPAN first, as
there's a Config::Properties module out there:
so I would see if that suits your needs.

You might want to also look into including a way of checking this into
CVS so that you can easily (hah!) revert back to an old setting.


More information about the spug-list mailing list