M
Marc Lucksch
Brad said:Whether or not this will serve your needs, I think one fairly
straight-forward data structure that can faithfully represent
typical ini file data is pairs of pairs. A "pairs" structure
is an array of single-key hashes as defined in
http://yaml.org/type/pairs.html
I didn't know about that one, this is an completely object based model.
(Or function based). Had I known about this one beforehand, I probably
would have just used it.
But what I want to have now, is more a perlish way to represent this
kind of data. While there can be multiple keys in one section, it is
quite rare. (The only once I know from the top of my head are fuse= and
surface_hit_effects=). There are also .ini files with sections out there
which have unique names. The current access I want is more perlish and easy.
How would you for example set the second fuse of the third ship
(section?) An operation likely to occour...
my @ships=$ini->get_values( "Ships" );
my $third=$ships[2];
my @fuses=$third->get_pos("fuse");
$third->set_pos("fuse",["fusename",0,10],$fuses[1]);
OR
($ini->get_pos( "Ship"
))[2]->set_pos("fuse",["fusename",0,10],(($ini->get_pos( "Ship"
))[2]->get_pos("fuse"))[1]
I want it more like:
$ini->{Ship}->[2]->{"fuse"}->[1]=["fusename",0,10];
And for the nickname of the only pilot:
$ini->{Pilot}->{"nickname"}->[0]="li_pilot_elite"; #->[0] is needed
# otherwise it would be ambigious, add another nickname or replace the
# first/all.
$ini->{Pilot}->[0]->{"nickname"}->[0]->[0]="li_pilot_elite";
This makes it easier to use and that should be (IMHO) a big focus in
development, even if I have to rack my brain over this and/or annoy you
guys with posts about it. (Those actually helped me a lot, thanks to all
again)
__POD__
Short term and style definition: (ini-file, Value can be escaped)
[Section]
Key = Value [, Value]; Comment
[;SkippedSection]
Yes, and thanks again for the nice module hint, maybe you can add aIn your case the typical ini data is enhanced by assuming that
comma separated values should be loaded as arrays.
solution to my critism (Setting a value for specific key) to your nice
module
Marc "Maluku" Lucksch