in reply to Cannot print line

Although the issue has been solved in a few different ways, I'd like to point out that one should be using the three-argument form of open (I always prefer to use a variable as opposed to bareword too):

my $filename = "/path/to/filename.txt"; open my $fh, '<', $filename; or die "Can't open the file $filename for reading: $!";

EDIT: AnomalousMonk pointed out my brain fart usage of the filehandle instead of a variable in the die statement. Fixed

-stevieb

Replies are listed 'Best First'.
Re^2: Cannot print line
by AnomalousMonk (Archbishop) on Nov 28, 2014 at 16:20 UTC
    open my $fh, '<', "/path/to/filename.txt"
      or die "Can't open the file $fh for reading: $!";

    $fh is the filehandle object (or whatever the proper term is). Perhaps better as:
        my $filename = '/path/to/filename.txt';
        open my $fh, '<', $filename or die "Opening '$filename' for reading: $!";

      D'oh! Of course! Thanks for catching that :) My original comment has been corrected.