-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.pl
45 lines (34 loc) · 968 Bytes
/
process.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
use strict;
use warnings;
use Krheo::File;
use Krheo::Utils;
use Symbol;
use Data::Dumper;
use Getopt::Long;
my ( $infos_file, $config_file, $template_file );
GetOptions (
'infos|i=s' => \$infos_file,
'conf|c=s' => \$config_file,
'template|t=s' => \$template_file,
);
if ( !$infos_file || !$config_file || !$template_file ) {
die "missing argument";
}
die "$infos_file doesn't exist. Nothing to do today :)" unless (-e $infos_file);
my $todo = Krheo::Utils::to_do($infos_file);
my $config = Krheo::File->in($config_file);
open( TMPL, "<$template_file" ) || die "could not open $template_file for reading: $!";
my $new;
while (<TMPL>) {
$new .= $_;
}
foreach my $type_list ( keys %$config ) {
my $content = "";
$content .= $_->dmp for @{ $config->{$type_list} };
$content .= $_->dmp for @{ $todo->{$type_list} };
$new =~ s/<<$type_list>>/$content/;
}
open (FH, ">$config_file");
print FH $new;
close (FH);