#! /usr/bin/perl use strict; use warnings; while ( my $line = ) { chomp $line; # split into: $1: test result, $2: test number, $3 - other string if ( $line =~ m/^(.+?)\s+(\d+)\s+-\s+(.+)/ ) { printf "%-6s %3d - %s\n", $1, $2, $3; } # other lines are printed as they are... else { print $line, "\n"; } } __DATA__ ok 1 - bla bla bla ok 2 - foo not ok 3 - bar ... not ok 12 - beispiel