Read a File Line by Line in Perl
Open a filehandle and iterate over a text file one line at a time, chomping trailing newlines.
Author:
chris
// Language: Perl
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, '<', 'data.txt') or die "Cannot open data.txt: $!";
while (my $line = <$fh>) {
chomp $line;
print "$line\n";
}
close($fh);