Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: First attempt at bringing in file for input/output

by morgon (Priest)
on Oct 20, 2018 at 01:02 UTC ( [id://1224365]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1224365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found