Closed Thread
Results 1 to 3 of 3

Thread: more help with perl

  1. #1
    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

  2. #2
    FWS Addict atlas has a spectacular aura aboutatlas has a spectacular aura about atlas's Avatar
    Join Date
    Nov 2000
    Posts
    501

    For a datafile like:
    john doe|18|14|jeff|green

    Code:
    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

  3. #3
    thanx looks very easy

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts