Click here to get back home

No connection using LWP

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
No connection using LWP Praveen 10-27-2006
Posted by Praveen on October 27, 2006, 5:30 pm
Please log in for more thread options


Hi,
I have just started learning LWP by using O'Relliy book. I wrote this
as my first program. When I executed it, nothing comes out and the
program kept on running. Ultimetly I have to cancle the program using
cntrl-C.
Here is the code:

use strict;
use LWP::Simple;

my $catalog = get("http://www.yahoo.com");
my $count = 0;
while ($catalog =~ -mgi){
        print "$_";
        $count++;
        
        }
print "$count\n";

Please let me know what is wrong. I am


Posted by John W. Krahn on October 27, 2006, 7:29 pm
Please log in for more thread options


Praveen wrote:
>
> I have just started learning LWP by using O'Relliy book. I wrote this
> as my first program. When I executed it, nothing comes out and the
> program kept on running. Ultimetly I have to cancle the program using
> cntrl-C.
> Here is the code:

You should enable the warnings pragma, it would have told you:

Use of uninitialized value in pattern match (m//) at -e line 9.


use warnings;

> use strict;
> use LWP::Simple;
>
> my $catalog = get("http://www.yahoo.com");
> my $count = 0;
> while ($catalog =~ -mgi){
^
^
You have a unary minus sign in front of the match operator so that is the same
as writing:

while ( $catalog =~ -( $_ =~ mgi ) ) {


>         print "$_";

You are not putting anything into $_ so with warnings enabled this will also
give you a warning:

Use of uninitialized value in concatenation (.) or string at -e line 10.


>         $count++;
>         
>         }
> print "$count\n";



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall

Similar ThreadsPosted
Net::FTP connection status March 15, 2006, 3:34 am
net::sftp connection close May 4, 2006, 6:27 am
NET::SFTP - how to close connection September 28, 2006, 7:22 am
Passing a DBI connection between [Unix] processes January 7, 2005, 1:01 pm
How do I force a close connection in SOAP January 26, 2006, 1:00 pm
How to include a connection file in perl December 2, 2006, 3:11 pm
Need to handle the NNTP connection timeout in my code February 8, 2007, 4:51 am
PARI stack overflow during long Net::SFTP connection July 16, 2004, 3:20 am
IPV6 socket connection, with a link-local address January 11, 2008, 1:12 pm
Segmentation violation in Math:Pari when used in connection with Thread:Pool February 2, 2006, 4:18 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap