#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @excel_rows; # blockweises einlesen und nicht zeilenweise # ein block endet mit "ENDJOB" local $/ = "ENDJOB\n"; # einlesen der daten, hier aus __DATA__. Dies auf # das Einlesen einer Datei zu übertragen bleibt dem geneigen # Leser überlassen while ( my $block = ) { my @found = $block =~ m{ ^ TYPE \s+ RFORM \s+ REC-SIZE \s+ # finde die Zeile (\w+) \s+ (\w+) \s+ (\d+) .*? # erste gruppe ist type # zweite gruppe ist RFORM # dritte gruppe ist REC-SIZE ^ CREATION \s+ LAST-RD \s+ (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}) \s+ # creation (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}) \s+ # last-rd .*? ^ STATE \s+ EXEC_COPIES \s+ (\w+) \s+ (\d+) .*? ^ DATA-BEGIN \s+ DATA-END \s+ RELEASE \s+ (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}) \s+ # found-begin (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}) \s+ # found-end (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}) \s+ # release }xms; my %info = ( TYPE => $found[0], RFORM => $found[1], 'REC-SIZE' => $found[2], CREATION => $found[3], 'LAST-RD' => $found[4], STATE => $found[5], EXEC_COPIES => $found[6], 'DATA-BEGIN' => $found[7], 'DATA-END' => $found[8], RELEASE => $found[9], ); push @excel_rows, \%info; } print Dumper \@excel_rows; __DATA__ LISTFILE:DIRECTORY NAME=MAX:\TEST.0001; STARTED STARTING TIME 2013-07-05 21:24:01 USER MACHINE4/HEIMO 220: SERVICE READY FOR NEW USER. SUPI 230: USER LOGGED IN, PROCEED. SUPI TYPE RFORM REC-SIZE SAM FIX 8192 CREATION LAST-RD 2010-05-13 00:37:32 2013-07-05 12:56:17 STATE EXEC_COPIES READY 2 DATA-BEGIN DATA-END RELEASE 2013-07-05 12:05:10 2013-07-05 12:23:48 2013-07-05 12:56:52 ENDJOB LISTFILE:DIRECTORY NAME=MAX:\TEST.0001; STARTED STARTING TIME 2013-07-05 21:24:01 USER MACHINE4/HEIMO 220: SERVICE READY FOR NEW USER. SUPI 230: USER LOGGED IN, PROCEED. SUPI TYPE RFORM REC-SIZE SAM FIX 8200 CREATION LAST-RD 2010-05-12 00:37:32 2013-07-06 12:56:17 STATE EXEC_COPIES READY 3 DATA-BEGIN DATA-END RELEASE 2013-07-06 12:06:10 2013-07-06 12:26:48 2013-07-06 12:58:52 ENDJOB