Changeset 1905 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Conf.pm


Ignore:
Timestamp:
Oct 9, 2014, 12:14:42 PM (10 years ago)
Author:
Bruno Cornec
Message:
  • pb_conf_write is indeed working and tested now (git error)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Conf.pm

    r1904 r1905  
    2929 
    3030our @ISA = qw(Exporter);
    31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_print pb_conf_get_all);
     31our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_print pb_conf_get_all pb_conf_cache);
    3232($VERSION,$REVISION) = pb_version_init();
    3333
     
    118118open(CONF,$cf) || confess "Unable to open $cf";
    119119while(<CONF>) {
     120    next if (/^#/);
    120121    if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.]+)\s*=\s*(.*)$/) {
    121122        pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
     
    233234
    234235my $conffile = shift;
    235 my $h = $_;
    236 
    237 open(CONF,"> $conffile") || confess "Unbale to wirte into $conffile";
     236my $h = shift;
     237
     238confess "No configuration file defined to write into !" if (not defined $conffile);
     239confess "No hash defined to read from !" if (not defined $h);
     240open(CONF,"> $conffile") || confess "Unable to write into $conffile";
    238241
    239242foreach my $p (keys %$h) {
    240     foreach my $key ($p) {
    241         print CONF "$p $key = $p->{$key}\n";
     243    my $j = $h->{$p};
     244    foreach my $k (keys %$j) {
     245        print CONF "$p $k = $j->{$k}\n";
    242246    }
    243247}
Note: See TracChangeset for help on using the changeset viewer.