lilalo

view l3config.pm @ 24:4b86595adb4b

Написал что нового в 0.2.2
author devi
date Wed Nov 02 19:25:39 2005 +0200 (2005-11-02)
parents
children ba4d6515b8fd
line source
1 package l3config;
3 use Exporter;
4 use Getopt::Long;
6 @ISA = ('Exporter');
7 @EXPORT = qw(%Config &init_config);
9 our $Config_File = "labmaker.conf";
10 our %Config = (
11 "skip_empty" => "yes",
12 "skip_interrupted" => "no",
13 "skip_wrong" => "no",
14 "editors" => ["vi", "pico", "ee", "vim"],
15 "pagers" => ["more", "less", "zmore", "zless", "info",
16 "man", "mc", "trafshow", "screen", "cfdisk",
17 "trafshow-bsd", "yes", "lynx", "links", "centericq"
18 ],
19 "terminal" => ["mc"],
20 "suppress_editors" => "yes",
21 "suppress_pagers" => "yes",
22 "suppress_terminal" => "yes",
24 "terminal_width" => 100,
25 "terminal_height" => 100,
26 "verbose" => "yes",
28 "head_lines" => 5,
29 "tail_lines" => 5,
30 "cache_head_lines" => 5,
31 "cache_tail_lines" => 5,
32 "skip_text" => "...",
33 "show_time" => "yes",
34 "show_diffs" => "yes",
35 "show_comments" => "yes",
37 "input" => "/root/.labmaker",
38 "diffs" => "",
39 "input_mask" => "*.script",
40 "encoding" => "utf-8",
42 "cache" => "/tmp/report.xml",
44 "output" => "/tmp/report.html",
45 #"output" => "report.xml",
46 "output_mask" => "INDEX",
47 "output_format" => "html",
49 "signature" => "#lm:",
50 "from" => "",
51 "to" => "",
52 "lab" => "",
53 "keywords" => "linux command",
54 "files_keywords" => "linux file",
56 comment_width => "300",
57 time_width => "60",
59 "course-name" => "",
60 "course-code" => "",
61 "course-date" => "",
62 "course-center" => "",
63 "course-trainer" => "",
64 "course-student" => "",
65 );
67 sub read_config_file
68 {
69 my $config = $_[0];
70 my $filename = $_[1];
71 open(CONFIG, "$filename")
72 or return;
73 while (<CONFIG>) {
74 s/#.*//;
75 next if /^\s*$/;
76 my ($var, $val) = split /\s*=\s*/, $_, 2;
77 $var =~ s/\s*//;
78 $config->{$var} = $val;
79 }
80 close(CONFIG);
81 }
84 sub init_config
85 {
86 my %argv_config;
87 my %file_config;
88 read_config_file(\%file_config, $Config_File);
89 GetOptions(\%argv_config, map "$_=s", keys %Config);
90 %Config = (%Config, %file_config, %argv_config);
91 }