Parsing a remote file

I am trying to open a file on a website.  Step through the lines and parse out the information.  What I am having trouble with is opening the remote file.  Specifically how do I read a line.  I know that there is a way to do this.   I have been pointed in the direction of the LWP module, but I am still having problems.

Thanks.
Brian
BrianGAsked:
Who is Participating?
 
khacharnConnect With a Mentor Commented:
hi brian
the solution to your problem is ~

1) use the Lwp::Simple module to get the file(on the we-site) to your machine.
the  script will be something like this
****************************************
use Lwp::Simple;
$pagefetched = get('www.xyz.com/page/page.html);
****************************************
Now you have the html page you wanted in the String $pagefetched..

2) You can now print this String to a file(thats what i did)
****************************************
open(File,">pagefetched.html);
print File $pagefetched;
****************************************

3) Now you can parse the file(pagefetched.html) to filter the information you want..using the regular expressions
****************************************
while ($linebyline = <File>)
{
#here you can process or parse the file line by lien to filterout the infomation you want..
}
****************************************

Hope this help
Do ask me anyting on this..
Nitin
0
 
ozoCommented:
What problems are you having with the LWP module?
0
 
clockwatcherCommented:
Why would you want to print it to a file?

use LWP::Simple;

$page = get('http://www.experts-exchange.com');

@lines = split('\n',$page);

foreach $line (@lines) {
  print "$line\n";
}




0
 
BrianGAuthor Commented:
Both answers are good.  A don't really need to print the lines to a file though, but that might actually be useful for later.  Thanks for your answers and comments.
0
All Courses

From novice to tech pro — start learning today.