PDA

View Full Version : more help with perl



LawTown Junky
January 22nd, 2001, 11:46
if i make a file say called data.txt or something stupid and in this file it has lines like this

john doe|18|14|jeff|green

where john doe is the name then the age and then lets say fav number and then fav color


how do i have it read this file and print on the page

name: john doe
age: 18
fav numba: 14
fav color: green

yet anotha simple task that i do not know how to do

atlas
January 22nd, 2001, 12:02
For a datafile like:
john doe|18|14|jeff|green




open(FILE,"/path/to/file");

while(<FILE>)
{
my($name, $age, $favoriteNumber, $thatJeffThing, $favoriteColor) = split(/\|/);
print "all the stuff out however you want";
}

close(FILE);



mjk@atlascgi.com

LawTown Junky
January 23rd, 2001, 07:51
thanx looks very easy