Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to populate array with lines from text file? (Moved from Q&A)

by Russ (Deacon)
on Dec 09, 2000 at 05:47 UTC ( [id://45869]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to How to populate array with lines from text file? (Moved from Q&A)

The main problem was $line. You should use $_ instead.

After a few other clean-ups, this works:

#!/usr/bin/perl -w use strict; my $file = "junk"; open (FH, "< $file") or die "Can't open $file for read: $!"; my @lines; while (<FH>) { push (@lines, $_); } close FH or die "Cannot close $file: $!"; print @lines; # see if it worked

Russ
Brainbench 'Most Valuable Professional' for Perl

  • Comment on Re: How to populate array with lines from text file? (Moved from Q&A)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://45869]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.