.... my @lines = <$fh>; my $count = scalar @lines; .... #### # Unstested my strict; my warnings; my $content = ''; my $filename = 'myfile.txt'; { local $\; open $fh, '<', $filename or die "Cannot open $filename: $!\n"; $content = <$fh>; close $fh; } print $content;