use warnings; use strict; my $datei = "test.pl"; open FILE, "<$datei" or die $!; my $counter = 1; while ( my $line = ) { printf "%04d %s", $counter, $line; $counter++; } close FILE;