Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: How to read from a .txt

by Jim (Curate)
on Jul 01, 2013 at 03:01 UTC ( #1041715=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How to read from a .txt
in thread How to read from a .txt

Here's how to read records (lines) from a plain text file in the ASCII character encoding:

use strict; use warnings; use autodie qw( open close ); use English qw( -no_match_vars ); @ARGV == 1 or die "Usage: perl $PROGRAM_NAME <input file>\n"; my $input_file = shift; open my $fh, '<:encoding(ASCII)', $input_file; RECORD: while (my $record = <$fh>) { # Do something with record... } close $fh;


Comment on Re^4: How to read from a .txt
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-08-28 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls