Thread ein paar fragen - hilfe :/: njaa perl halt ^^ (46 answers)
Opened by Gast at 2005-07-05 21:49

Ronnie
 2005-07-06 19:20
#5180 #5180
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
phaylon hat Recht, es hängt primär davon ab wie deine Textdatei aussieht. Mal ein Beispiel wo alles simpel untereinander steht (würde YAML als Alternative empfehlen):
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
24
25
26
27
28
29
30
31
#!/usr/bin/perl 

use strict;
use warnings;

use Data::Dumper;

my @persons;
$persons[0] = [];

while(<DATA>) {
chomp;
push @persons, [] and next if /^\s*$/;
push @{$persons[-1]}, $_;
}

#print Dumper \@persons;
print Dumper [grep { $_->[2] eq 'male' } @persons];

_ _DATA_ _
Horst
Mustermann
male

Tina
Mustermann
female

Otto
Mustermann
male

EDIT: Typo fixed\n\n

<!--EDIT|Ronnie|1120665609-->

View full thread ein paar fragen - hilfe :/: njaa perl halt ^^