#!/usr/bin/perl use strict; use warnings; while ( my $line = ) { # nutze Magie von Perl's split() operator; Details: perldoc -f split my @fields = do { local $_ = $line; split; }; my $anzahl = @fields; # anzahl kontrollieren if ( 8 == $anzahl ) { local $, = ' '; print $anzahl, ':', @fields[3..6], "\n"; } elsif ( 2 == $anzahl ) { # vielleicht weitere checks um zu erfahren, welche Spalten man erwischt local $, = ' ', print $anzahl, ':', @fields, "\n"; } # Fehlerfall else { local $, = ' '; print $anzahl, ':', @fields, "\n"; } } __DATA__ 0 000123456 Name 07/09 86,00 7,00 79,00R 0,00 Vorname 8,00N