CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Open File, Split, then Split again!

 



geoff_xrx
stranger

Jun 26, 2001, 5:44 AM

Post #1 of 4 (373 views)
Open File, Split, then Split again! Can't Post

How do I Open a File ("Test.txt")
then Split it by line (into an array)
then split it again (I can do this part)

Reall, I just need to know how to open the file and split by each line

open (FileTest, "c:\\test.txt"); right?

what is the 'or die' thing that I saw in another post?

Thanks





geoff_xrx
stranger

Jun 26, 2001, 6:00 AM

Post #2 of 4 (372 views)
Re: Open File, Split, then Split again! [In reply to] Can't Post

never mind :)

open (FileTest,"c:\\test.txt");
@lines = <FileTest>;
close FileTest;
foreach (@lines) {
@tmp = split /: /;

etc...




geoff_xrx
stranger

Jun 26, 2001, 6:17 AM

Post #3 of 4 (372 views)
Re: Open File, Split, then Split again! [In reply to] Can't Post

ok new question:

@tmp = split /: /;

now some lines have nothing in them (sort of)
like for example:

Address: 170 ThisStreet St
Address2:

I can split the line by ': '...no problem
$tmp[0] = left half
$tmp[1] = right half
in the cas of address2...how do I test if there is nothing there? either a NewLine or space?

Thanks!









geoff_xrx
stranger

Jun 26, 2001, 7:14 AM

Post #4 of 4 (370 views)
Re: Open File, Split, then Split again! [In reply to] Can't Post

got that too now :)

I must say this forums is SLOW! No one is here!!

(Im used to vbworld forums...response in mintes usually)




 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives