Thread Suche in bestimmten Zeilen nach bestimmtem Wort (28 answers)
Opened by kabazza at 2007-01-04 19:25

renee
 2007-01-11 18:03
#72889 #72889
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
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;
use Data::Dumper;

my @result;

my $file = '/path/to/file';
open my $fh,"<",$file or die $!;
local $/ = "\n...\n";
while(my $entry = <$fh>){
my $bool = 0;
my @lines = split /\n/,$entry;
my @aacc = grep{/^(?:AA|CC)/}@lines;
my @temp = grep{/^(?:BB|DD|EE)/}@lines;
if(grep{/Mercedes/}@aacc){
push @result,\@temp;
}
}
close $fh;

print Dumper(\@result);
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Suche in bestimmten Zeilen nach bestimmtem Wort