#!/usr/bin/perl use warnings; use strict; my $filename = "myfile"; open(my $fh, "<", $filename); my $nr = 0; while (my $l = <$fh>) { $nr++; chomp($l); print "$nr.\t$l\n"; } close($fh);