first 2 words only!!!!!!!!!!!!
Posted by rick (rick), 11 November 2007I want only the first 2 words from every line of a particular file and store them into a array.But every time I try to do it only the first 2 elements of 1st line are picked not every first 2 elements of every line.
I really dont know what is the problem with the code.plz advice
my code is:
open(INFILE,"<c.txt") or die "cant open file:$!\n";
$stat= join(" ",@x[0..1]);
a line from the file is:
(this is just a example)
Posted by admin (Graham Ellis), 11 November 2007You need to process each line of the data separatly - you're slurping the whole lot into a list, joining it together, and just pulling the first two elements off the whole. Here's a modified sample doing the sort of thing you want:
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho