- while
Process an entire file line by line (while, cat)
- while - executes as long as there is something in $line, as long as there are lines in the file
- Loop over file (name hard-coded) and print every line (UNIX cat)
examples/files-perl/cat.pl
#!/usr/bin/perl use strict; use warnings; my $filename = "input.txt"; open(my $fh, "<", $filename) or die "Could not open '$filename'\n"; while (my $line = <$fh>) { print $line; }
Instead of printing the line you could do anything with it.