use strict; use warnings; my $LOGFILE = 'file.log'; my @contents = (); open my $fh, "<$LOGFILE" or die "Failed to open $LOGFILE"; while (my $line = <$fh>) { push @contents, $line; } close $fh; print @contents;