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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
use warnings;
use strict;
my $path = "/ist/egal";
my $infile = "input.txt";
my $outfile = "output.csv";
my $found = "";
my $count = "";
my @Dealer = ();
my $firstNR = "";
my $secNR = "";
my $thirdNR = "";
open(IN, "<$path/$infile") || die "Cannot open file $infile!\n";
while(<IN>) {
chomp;
my $line = $_;
if($line =~ /^(# suchmuster1)(\d+)(suchmuster2)/)
{
$firstNR = $2;
$found = 2;
}
elsif($line =~ /^(suchmuster3)(.+)/)
{
$secNR = $2;
}
elsif($line =~ /^(suchmuster4)(test)/i)
{
$thirdNR = $2;
}
if($found eq "2")
{
my $new_line = $firstNR.";".$secNR.";".$thirdNR.";";
push(@Dealer, $new_line);
$found = "";
$firstNR = "";
$secNR = "";
}
}
close(IN);
open(OUT, ">>$path/$outfile") || die "Cannot open and write file $outfile!\n";
foreach my $zeile (@Dealer)
{
print OUT $zeile."\n";
$count++;
}
close(OUT);
print "Habe $count Datensaetze gefunden\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
use strict;
use warnings;
my $file = '/path/to/file.txt';
my @array;
{
local $/ = "\n#";
open my $fh,'<',$file or die $!;
while( my $article = <$fh> ){
my @info = $article =~ /^suchmuster1 (\d+) suchmuster2.*?suchmuster3([^\n]+).*suchmuster4(test)/i;
push @array,join(";",@info);
}
}
print $_,"\n" for @array;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl
use strict;
use warnings;
my $file = "/root/Desktop/export_28-02-07.txt";
my @array;
{
local $/ = "\n#";
open my $fh, '<',$file or die $!;
while( my $line = <$fh> ){
my @info = $line =~ /^suchmuster1 =(\d+)/;
@info = $line =~ /^suchmuster2 (.+)/;
@info = $line =~ /^suchmuster3 (Hallo)/i;
@info = $line =~ /^suchmuster4 (Hello)/i;
push @array, join(";", @info);
}
}
foreach my $zeile (@array) {
print $zeile."\n";
}
my @info = $line =~ /^suchmuster1 =(\d+)/;
1
2
3
4
my @info = $line =~ /^suchmuster1 =(\d+)/;
@info = $line =~ /^suchmuster2 (.+)/;
@info = $line =~ /^suchmuster3 (Hallo)/i;
@info = $line =~ /^suchmuster4 (Hello)/i;
1
2
3
4
my @info = $line =~ /^suchmuster1 =(\d+)/;
push @info, $line =~ /^suchmuster2 (.+)/;
push @info, $line =~ /^suchmuster3 (Hallo)/i;
push @info, $line =~ /^suchmuster4 (Hello)/i;
1
2
3
4
5
6
7
8
9
10
11
12
open my $fh, '<',$file or die $!;
while( my $line = <$fh> ){
chomp($line);
my @info = $line =~ /^suchmuster1=(\d+)/;
push @info, $line =~ /^suchmuster2: (.+)/;
push @info, $line =~ /^suchmuster3: (test1)/i;
push @info, $line =~ /^suchmuster4: (test2)/i;
push @info, $line =~ /^suchmuster5: (test3)/i;
push @info, $line =~ /^suchmuster6: (test4)/i;
my $new_line = join(";",@info);
print $new_line."\n";
}
Quote
9876542
123BCA9
test3
0123455
ABC123A
test4
Quote9876542;123BCA9;;test3;
10 Einträge, 1 Seite |