Leser: 1
|< 1 2 3 >| | 25 Einträge, 3 Seiten |
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
foreach $line (@data) { if ($line =~ /start:/) { @stst = (split /\:/, $line); print "<font size=+2>$stst[1]</font size>\n"; print "<table cols=7 BORDER=1 cellpadding=1 cellspacing=1>\n"; print "<tr>\n"; print "<td width=150 align=right><b>Hostname</b></td>\n"; print "<td width=120 align=right><b>IP-Adresse</b></td>\n"; print "<td width=150 align=right><b>Model</b></td>\n"; print "<td width=80 align=right><b>uptime (d)</b></td>\n"; print "<td width=60 align=right><b>OS</b></td>\n"; print "<td width=100 align=right><b>Last Update</b></td>\n"; print "<td width=50 align=right><b>SN</b></td>\n"; print "</tr>"; } elsif ($line =~ /end:/) { print "</table>\n"; print "<br><br>\n"; } else { print "<tr>"; $file=$path . ".html" . $line; if (-f $file) { open(TEMP,$file); } else { @myunkn= split /\./, $file,3; $myunknown=$myunkn[0] . "." . $myunkn[1]; open(TEMP,$myunknown); $file=$myunknown; } @lines=<TEMP>;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
@Host=grep {/Host:/} @lines; @AHost=split (/ /,$Host[0]); $filepath=$htmlpath . $line . ".html"; @Domain=grep {/DNS domain name:/} @lines; @ADomain=split (/ /,$Domain[0]); print "<td width=150 align=right><a href=$filepath>$AHost[1].$ADomain</a></td>\n"; @IP=grep {/IPAdress:/} @lines; print "<td width=150 align=right>"; foreach $run (@IP) { @AIP=split (/ /,$run); print $AIP[1] . "<br>"; } print "</td>\n";
Use of uninitialized value in split" und "Use of uninitialized value in concatenation (.) or string
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 64 65 66 67 68 69 70
#!/opt/perl5/bin/perl -w # die $path -variable repraesentiert den Pfad zu den collect-files $htmlbasepath="/"; $htmlpath=$htmlbasepath . "cfg2html/server/"; #$basepath="/web/html/"; $basepath="/home/rioc/Desktop/perl_test/"; $path=$basepath . "cfg2html/server/"; opendir(DIRHANDLE, $path) or die "Directory not available"; while ( defined ($filename = readdir(DIRHANDLE))) { @list=(@list,$filename); } @list=sort (@list); @machinelist = grep {/.html/} @list; @allmachines=(); foreach $machine (@machinelist) { $machine =~ s///; @allmachines=(@allmachines,$machine); } @domains=(); foreach $machine (@allmachines) { $ok=0; @splitpieces = split /\./, $machine; if ($splitpieces[1]) { $dmn=$splitpieces[1] } else { $dmn="unknown"; $splitpieces[1]="unknown"; } foreach $try (@domains) { if ($try eq $dmn) {$ok=1}; }; if ($ok ne 1) {@domains=(@domains,$dmn)}; $ok=0; $machine = join '.', @splitpieces; }; @domains=sort(@domains); @data=(); foreach $domain (@domains) { @$domain=(); foreach $machine (@allmachines) { @namepartsplit= split /\./, $machine; if ( $namepartsplit[1] eq $domain ) { @$domain=(@$domain,$machine); }; }; @data=(@data,"start:$domain",@$domain,"end:$domain",); };
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 64 65 66 67 68 69 70 71 72 73
foreach $line (@data) { if ($line =~ /start:/) { @stst = (split /\:/, $line); print "<font size=+2>$stst[1]</font size>\n", print "<table cols=7 BORDER=1 cellpadding=1 cellspacing=1>\n", print "<tr>\n", print "<td width=150 align=right><b>Hostname</b></td>\n", print "<td width=120 align=right><b>IP-Adresse</b></td>\n", print "<td width=150 align=right><b>Model</b></td>\n", print "<td width=80 align=right><b>uptime (d)</b></td>\n", print "<td width=60 align=right><b>OS</b></td>\n", print "<td width=100 align=right><b>Last Update</b></td>\n", print "<td width=50 align=right><b>SN</b></td>\n", print "</tr>"; } elsif ($line =~ /end:/) { print "</table>\n"; print "<br><br>\n"; } else { print "<tr>"; $file=$path . $line; if (-f $file) { open(TEMP,$file)or die "Can't open $file: $!"; } else { @myunkn= split /\./, $file,3; $myunknown=$myunkn[0] . "." . $myunkn[1]; open(TEMP,$myunknown) or die "Can't open $file: $!"; $file=$myunknown; } @lines=<TEMP>; @Host=grep {/Host:/} @lines; @AHost=split (/ /,$Host[0]); $filepath=$htmlpath . $line; @Domain=grep {/DNS domain name:/} @lines; @ADomain=split (/ /,$Domain[0]); print "<td width=150 align=right><a href=$filepath>$AHost[1] . $ADomain</a></td>\n"; @IP=grep {/IPAdress:/} @lines; print "<td width=150 align=right>"; foreach $run (@IP) { @AIP=split (/ /,$run); print $AIP[1] . "<br>"; } print "</td>\n"; @Model=grep {/Model:/} @lines; @AModel=split (/ /,$Model[0]); print "<td width=150 align=right>$AModel[1]</td>\n"; [...] ... hier wären weitere greps im gleichen Stil verfasst ... [...] @SN=grep {/serialNumber/} @lines; @ASN=split (/=/,$SN[0]); print "<td width=150 align=right>$ASN[1]</td>\n"; print "</tr>"; };
rioc+2008-04-11 13:24:15--Code (perl): (dl )1 2 3 4 5 6 7 8 9 10 11print "<font size=+2>$stst[1]</font size>\n"; print "<table cols=7 BORDER=1 cellpadding=1 cellspacing=1>\n"; print "<tr>\n"; print "<td width=150 align=right><b>Hostname</b></td>\n"; print "<td width=120 align=right><b>IP-Adresse</b></td>\n"; print "<td width=150 align=right><b>Model</b></td>\n"; print "<td width=80 align=right><b>uptime (d)</b></td>\n"; print "<td width=60 align=right><b>OS</b></td>\n"; print "<td width=100 align=right><b>Last Update</b></td>\n"; print "<td width=50 align=right><b>SN</b></td>\n"; print "</tr>";
1 2 3 4 5 6 7 8 9 10 11 12 13
print <<"EOM"; <font size="+2">$stst[1]</font> <table cols=7 BORDER=1 cellpadding=1 cellspacing=1> <tr> <td width=150 align=right><b>Hostname</b></td> <td width=120 align=right><b>IP-Adresse</b></td> <td width=150 align=right><b>Model</b></td> <td width=80 align=right><b>uptime (d)</b></td> <td width=60 align=right><b>OS</b></td> <td width=100 align=right><b>Last Update</b></td> <td width=50 align=right><b>SN</b></td> </tr> EOM
1 2 3 4 5 6 7 8
opendir(DIRHANDLE, $path) or die "Directory not available"; while ( defined ($filename = readdir(DIRHANDLE))) { @list=(@list,$filename); } @list=sort (@list); @machinelist = grep {/.html/} @list;
1 2 3
opendir(DIRHANDLE, $path) or die "Directory not available"; my @machinelist = grep{ /\.html/ } readdir(DIRHANDLE); closedir DIRHANDLE;
1 2 3 4 5
foreach $machine (@machinelist) { $machine =~ s///; @allmachines=(@allmachines,$machine); }
1 2 3 4 5
foreach $try (@domains) { if ($try eq $dmn) {$ok=1}; }; if ($ok ne 1) {@domains=(@domains,$dmn)};
1 2 3 4 5 6 7 8 9 10 11 12 13
foreach $domain (@domains) { @$domain=(); foreach $machine (@allmachines) { @namepartsplit= split /\./, $machine; if ( $namepartsplit[1] eq $domain ) { @$domain=(@$domain,$machine); }; }; @data=(@data,"start:$domain",@$domain,"end:$domain",); };
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl my $domain = 'unknown'; @$domain = (); print $domain; push @$domain, 'test'; print $domain;
|< 1 2 3 >| | 25 Einträge, 3 Seiten |