os="microsoft windows xp professional, , sp3, 5.1.2600"
$$f_lgr->debug("found xp") if $os =~ /xp/;
1
2
3
4
5
6
7
8
9
10
11
12
=========================================================================
==> start
=========================================================================
parameter -o ignored
main::createPreps: not implemented yet!
database version $Rev: 33 $
last usage Wed Nov 21 16:07:58 2012
found files with errors. Check logfile.
My::Subs::WayOut: Error code 0: normal program end
=========================================================================
==> stop
=========================================================================
2012-11-21T15:23:16 silver345Selbst, wenn ich die Zeile auskommentiere, werden die Fehlermeldungen geliefert.
1
2
3
4
5
6
7
use strict;
use warnings;
...
$fkt_ref->{package} = \&storePackage;
$fkt_ref->{profile} = \&storeProfile;
$fkt_ref->{host} = \&storeHost;
$fkt_ref->{log} = \&storeLog;
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
my @files; # stores working files
my @contend; # stores files for 2. run
if(-d $site->{PATH}) { # path points to folder
my $fldr = $site->{PATH}; # get all file names in folder
@files = <$fldr/*.xml>;
} else { # path points to a single file
@files = $site->{PATH};
}
foreach my $fl (@files) { # for all files in path
%ret = &getAttribs($site->{FILETYP}, $fl, \$logger);
while ( my($key, $value) = each(%ret) ) { # log all return values
$logger->debug("$key -> $value");
}
if($ret_ref->{ec} eq '251') { # missing field in xml file?
unshift(@wrongs, $fl); # store file name in error array
}
if($ret_ref->{ec} eq '250') { # file not redeable or does not exist
$logger->error("$fl: return code $ret_ref->{ec}");
&WayOut('250', $logger); # go out
}
# select sub depended from FILETYP
my $help = &{ $fkt_ref->{$fltype} }($ret_ref, \$logger);
my $desc ="db error";
if($help < 0) {
$desc = "$fltype $help: exist, skipped"; # do not store file name
} elsif($help > 0) {
$desc = "$fltype $help: inserted";
push @contend, $fl; # store file name for 2. run
} elsif($help == 0) { # something is wrong, log
unshift(@wrongs, $fl);
$desc = "$fltype $help: error, not stored";
}
$logger->debug("$fl: result $desc");
&storeWork($fl, $desc, \$logger);
}
given ($fltype) {
when("package") { $logger->debug("no 2. run"); }
when("profile") { $logger->debug("2. run required!");
my $sp_ret = 0;
foreach my $cont (@contend) {
$sp_ret = &storeContend($cont, $site->{OS}, \$logger);
if($sp_ret == 255) {
unshift(@wrongs, $cont); # store file in error array
}
}
}
when("host") { $logger->debug("no 2. run"); }
when("log") { $logger->debug("no 2. run"); }
}
if(@wrongs > 0) { # print file names with problems
$logger->info("found files with errors. Check logfile.");
foreach my $wrong (@wrongs) {
$logger->debug("wrong: $wrong");
}
} else {
$logger->info("found no files with errors.");
}
&closeDatabase(\@toClose, \$dbh);
&WayOut('0', $logger); # program end
1
2
3
4
5
6
7
8
9
sub storeLog {
my $f_vals = shift; # get ref to value hash
my $f_lgr = shift; # get ref to logger handler
my $SubName = (caller(0))[3];
my $os = $f_vals->{os};
$$f_lgr->debug("found XP") if $os =~ /xp professional/;
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
syntax error at ./check line 327, near ") {"
syntax error at ./check line 337, near "}"
syntax error at ./check line 346, near "}"
syntax error at ./check line 420, near ") {"
syntax error at ./check line 423, near ") {"
syntax error at ./check line 424, near ") {"
Global symbol "%attribs" requires explicit package name at ./check line 424.
Global symbol "%attribs" requires explicit package name at ./check line 425.
Global symbol "$f_FileType" requires explicit package name at ./check line 427.
Global symbol "$f_FileType" requires explicit package name at ./check line 428.
Global symbol "$doc" requires explicit package name at ./check line 431.
Global symbol "$f_FileType" requires explicit package name at ./check line 431.
Global symbol "%attribs" requires explicit package name at ./check line 432.
Global symbol "$attribs_ref" requires explicit package name at ./check line 435.
Global symbol "$attribs_ref" requires explicit package name at ./check line 437.
Global symbol "$attribs_ref" requires explicit package name at ./check line 441.
Global symbol "%attribs" requires explicit package name at ./check line 443.
Global symbol "$attribs_ref" requires explicit package name at ./check line 445.
syntax error at ./check line 447, near "}"
./check has too many errors.
use Switch 'Perl5', 'Perl6';
use Switch 'Perl5';
2012-11-22T13:05:18 silver345Noch mal zu Switch. Gibt es denn eine Alternative dazu außer elsif oder so?
1 2 3 4 5 6
my %switch = ( 10 => sub { print 10; }, 20 => sub { print 20; }, ); $switch{$given}->();
{ foo => sub { print 'das ist foo' }, bar => sub { print 'das ist bar' } }->{bar}->();