Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
There's more than one way to do things
 
PerlMonks  

(bbfu) (AoA?) Re: how do I open each line of a text file into seperate arrays?

by bbfu (Curate)
on Apr 30, 2001 at 21:11 UTC ( [id://76752]=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 do I open each line of a text file into seperate arrays?

You could use an array of arrays:

# open FILE while(<FILE>) { # The []'s make an anonymous array, so each element # of @lines is actually an array-ref. push @lines, [split /\|/, $_]; } print "Yep.\n" if $lines[0][0] eq 'foo'; # it will

HTH.

Upd: oops, fixed my array indexes. :-)

Upd2: damn, what was I thinking? Changed @lines = [...] to proper push.

Upd3: ARGH!!! Thanks for the eq catch, buckaduck. That's what I get when I try to rush a post... :-(

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.

Replies are listed 'Best First'.
Re: (bbfu) (AoA?) Re: how do I open each line of a text file into seperate arrays?
by buckaduck (Chaplain) on Apr 30, 2001 at 21:17 UTC
    print "Yep.\n" if $lines[0][0] == 'foo';
    I think you mean:
    print "Yep.\n" if $lines[0][0] eq 'foo';

    Just when you thought the updates were over...

    buckaduck

Re:{3} how do I open each line of a text file into seperate arrays?
by jeroenes (Priest) on May 01, 2001 at 14:18 UTC
    Yet Another Use for SuperSplit!

    use SuperSplit; $AoA = supersplit_open( /\|/, $filename );
    ...and it's all there in $AoA.

    Jeroen
    "We are not alone"(FZ)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76752]
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.