Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: How to read from a .txt

by stamp1982 (Novice)
on Jun 30, 2013 at 22:24 UTC ( #1041662=note: print w/ replies, xml ) Need Help??


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

If I started with some thing like this how will I join it to my code to work or make sense.

# Open a .txt file open(seq1, "<seq1.txt") or die $!; #Assign open files to arrays my @seq1 = <seq1>; print "@seq1";


Comment on Re^2: How to read from a .txt
Download Code
Re^3: How to read from a .txt
by o_0 (Initiate) on Jul 01, 2013 at 01:23 UTC
    Didn't try your code, but the syntax for open is usually this:
    open(my $fh, "<", "input.txt") or die "cannot open < input.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;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2015-07-06 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls