1
2
3
4
Spalte 1/ Zeile 1: "Personalnummer"/ Zeile 1: 0123456789
Spalte 2/ Zeile 1: "übertroffen": 1
Spalte 3/ Zeile 1: "erreicht": 0
Spalte 4/ Zeile 1: "motiviert": 1
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
#!/usr/bin/perl use strict; use warnings; my @keywords = qw( übertroffen erreicht motiviert); my @files = glob('/path/to/files'); my $regexp = join('|', map{ qr/\Q$_\E/ }sort{ length($b) <=> length($a) }@keywords ); for my $file (@files) { if( open(my $fh, '<', $file) ) { print "\n\n$file\n"; my $lc = 0; while( my $line = <$fh> ) { lc++; if($line =~/(\d{10})/) { print "Zeile $lc: $1\n"; } my $rc = 1; while( $line=~/^(.*?)($regexp)// ) { $rc+=length($1); print "Spalte $rc/ Zeile $lc: $2\n"; $rc+=length($2); } } close($fh); } else { warn "$file ERROR OPEN $!\n"; next; } }