in reply to First attempt at bringing in file for input/output

I'll add my two cents on top of what others have posted...

Firstly I would NOT use autodie until you've learned how to deal with files without it.

It's a shortcut for people that know what they are doing (and you're not quite there yet).

Then ALWAYS use strict;. ALWAYS. Absolutely ALWAYS.

The normal idiom for opening filehandles is this:

open my $fh, "<", "blah.txt" or die $!;
This declares a lexical file-handle and opens it, dying if there is an error.

Feel free to modify it, once you understand what it does.

Replies are listed 'Best First'.
Re^2: First attempt at bringing in file for input/output
by pryrt (Abbot) on Oct 20, 2018 at 20:22 UTC

    As stevieb pointed out, use v5.12; does enable strict.

    Quoting use:

    use VERSION also lexically enables all features... Similarly, if the specified Perl version is greater than or equal to 5.12.0, strictures are enabled lexically as with use strict.