10 Einträge, 1 Seite |
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
my $directory="/Perl/BugFiles";
opendir(RDIR, $directory) or die "das Verzeichnis konnte nicht geöffnet werden";
my @fileList= grep(!/^\.?$/, readdir(RDIR));
close(RDIR);
foreach $file(@fileList) {
open (WRITEFILE, ">/Perl/ExtractedData/data.txt");
open(READFILE, "</Perl/BugFiles/$file");
while (my $row=<READFILE>) {
if($row=~/<TITLE>(.+)-$/){
my $bugnumber=$1;
}
if($row=~/<a href="pkgreport\.cgi\?submitter=.+">(.+)<\/a>/) {
my $sender=$1;}
if($row==~/<a href="pkgreport\.cgi\?submitter=.+">(.+)<\/a>/) {
my $maintainer=$1;}
elsif($row=~/<a href="pkgreport\.cgi\?maint=">(.+)<\/a>/)
{ $maintainer="unknown";}
if($row =~/^Date:(.+)UTC\.$/){
my $date=$1;}
if($row=~/<pre class="message">Package:(.+)$/){
my $package=$1;}
elsif($row=~/<pre class="message">Package:"$/){
$package="unknown";}
if($row=~/^Severity:(.+)$/){
my $severity=$1;} }
my @zeile=($bugnumber, $sender, $maintainer, $date, $package, $severity);
print WRITEFILE $zeile;
}
1
2
3
my $zeile=join "\t", ($bugnumber, $sender, $maintainer, $date, $package, $severity);
print WRITEFILE $zeile;
print WRITEFILE join(",",$bugnumber, $sender, $maintainer, $date, $package, $severity);
1
2
3
4
if($row=~/<a href="pkgreport\.cgi\?submitter=.+">(.+)<\/a>/) {
my ($sender,$maintainer);
$maintainer = $sender = $1;
}
QuoteCode: (dl )1
2
3my $directory="/Perl/BugFiles";
opendir(RDIR, $directory) or die "das Verzeichnis konnte nicht geöffnet werden";
my @fileList= grep(!/^\.?$/, readdir(RDIR));
my @fileList= grep(!/^\.\.?$/, readdir(RDIR));
QuoteCode: (dl )1
2
3
4
5close(RDIR);
foreach $file(@fileList) {
open (WRITEFILE, ">/Perl/ExtractedData/data.txt");
open(READFILE, "</Perl/BugFiles/$file");
1
2
3
open (WRITEFILE, '>', '/Perl/ExtractedData/data.txt')
or die "could not open /Perl/ExtractedData/data.txt: $!";
[und analog weiter]
QuoteCode: (dl )1
2
3
4
5while (my $row=<READFILE>) {
if($row=~/<TITLE>(.+)-$/){
my $bugnumber=$1;
}
[... etc ...]
QuoteCode: (dl )1
2
3
4my @zeile=($bugnumber, $sender, $maintainer, $date, $package, $severity);
print WRITEFILE $zeile;
}
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
#!/usr/bin/perl
use strict;
use warnings;
my $html_report = '';
my $data_file = '';
my $content = '';
my $bug = parse_file($html_report);
add_to_file($bug);
sub parse_file{
my ($file) = @_;
local $/;
open(my $fh,'<',$html_report) or die $!;
my $content = <$fh>;
close $fh;
my ($bugnumber,$package) = $content =~ /<title>(#\d+)\s?([^\s]*?)\s*?-/i;
my ($submitter) = $content =~ /pkgreport\.cgi\?submitter=([^"]*?)/;
my ($maintainer) = $content =~ /pkgreport\.cgi\?maint=([^"]*?)/ ? "unknown" : $submitter;
my ($date) = $content =~ /Date:\s?(.*?)\s?UTC/;
my ($severity) = $content =~ /Severity:\s?(.*?);/;
return join(',',$bugnumber,$submitter,$maintainer,$package,$date,$severity);
}# parse_file
sub add_to_file{
my ($file,$bug) = @_;
open(my $fh,">>",$file) or die $!;
print $fh $bug,"\n";
close $fh;
}#add_to_file
10 Einträge, 1 Seite |