Closed Thread Icon

Topic awaiting preservation: Reading from a file to an array.. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12379" title="Pages that link to Topic awaiting preservation: Reading from a file to an array.. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Reading from a file to an array.. <span class="small">(Page 1 of 1)</span>\

 
Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-24-2002 19:00

I'm trying to put every line in a file into an array:
How do I printout just that second line?
(It's not so much the printing of the second line, I'm just trying to learn how to call just one element of the array)

# Read the file into an array.
open(DBBOOK,"<$bookdata")

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-25-2002 06:08

Your array is actually called "$raw_book", and that's why printing "$raw_entry[1]" shows nothing...

Correct code:

print "Line 2: " . $raw_book[1];


Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-25-2002 09:33

heh

FUCK! I hate it when it's a stupid error like that....

...so $raw_book[1] is what I was looking for....


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

« BackwardsOnwards »

Show Forum Drop Down Menu