#!/usr/bin/perl use strict; use warnings; open my $fh, '<', 'file.txt' or die "Can't open file: $!"; while ( my $line = <$fh> ){ chomp $line; # do stuff print "$line\n"; }