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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
File data



Jan 21, 2001, 9:20 AM

Post #1 of 2 (222 views)
File data Can't Post

Hello everyone!

The file on my server has two pieces of information formatted like this:
and as you can see, the two strings are separated by a "|"

I was looking for the code that will get the contents of a file and separate two strings from an open (I already have OPEN and CLOSE, and all I need is that code for getting the content and separate it).
This would save me the use of two files.

Thanks in advance!



Jan 21, 2001, 10:03 AM

Post #2 of 2 (220 views)
Re: File data [In reply to] Can't Post

If i read your post properly i assume this is what you would be looking for..
Here is some code that may help you out to "split" the data in the file..

$datafile = "cool.txt";
print "Content-type: text/html\n\n";
open (FILE, "$datafile") || print "Could not open $datafile ($!)";
flock FILE, 2;
flock FILE, 8;

foreach $line (@data) {
chomp $line;

#This line depends on how many items you have in the file .
#THe way you arrange the idems is buy separating them with commas.
#In this example i made it look like the file contained 3 items (Kelly|23|blond)

print "$item1 is $item2 in age and has $item3 hair\n";

have fun


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

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