Perl

How can you read a file and print every line?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

open(my $fh, ';
foreach my $line (@file) {
    print $line;
}

We can use the file handle without assigning it to an array:

open(my $fh, ') {
    print $line;
}