Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

LWP::Simple? Prototype mismatch?

by George_Sherston (Vicar)
on May 16, 2005 at 13:05 UTC ( [id://457438]=perlquestion: print w/replies, xml ) Need Help??

George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:

I just swept aside the dense curtain of cobwebs over the entrance to my cell and looked round the room I used to know so well but which I haven't for so long.. and my eye lighted on the Name Space node which I indexed ages ago. I wrote a script then to update the index and it worked fine. But now when I run it I get

Prototype mismatch: sub main::head vs ($) at ns.pl line 6

I think this is an LWP::Simple prob... but it's a complete new one on me. Has something change when I was in my Rip Van Winkle sleep?

If any kind monk can put me straight I'd be most grateful, and doubly glad because then I could update the wretched index. The bit of the script that (I think) is breaking down is
#!/usr/bin/perl -w use strict; use lib '/home/httpd/lib'; use CGI qw/:standard :cgi-lib/; use LWP::Simple; my $text = get 'http://www.perlmonks.net/index.pl?node_id=110166'; my %names = (George_Sherston => 110166); while ($text =~ s#<a HREF="/index\.pl\?node_id=(\d+)">.+?</a><BR> by < +a HREF="/index\.pl\?node_id=(\d+)">(.+?)</a> on \w{3} \d{1,2}, \d{4} +at# #) { unless (defined $names{$3}) { $names{$3} = $1; } }
Many thanks - it's lovely to be back in the hallowed halls.

Replies are listed 'Best First'.
Re: LWP::Simple? Prototype mismatch?
by Arunbear (Prior) on May 16, 2005 at 13:30 UTC
    This happens because both LWP::Simple and CGI are exporting a sub called head. You aren't using LWP::Simple::head so to prevent it from being imported you can replace
    use LWP::Simple;
    with
    use LWP::Simple qw/get/;

      This is why it's a good practice to always specify exactly what you're importing (either by listing it explicitly or by using an appropriate :TAG), and to explicitly say use Module () if you're not importing anything.

      Aaah... thankyou. Well, they've been building subs left right and centre.. I remember when this was open country as far as they eye could see.. that's progress.. Thanks again, JR
Re: LWP::Simple? Prototype mismatch?
by jeffa (Bishop) on May 16, 2005 at 13:34 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://457438]
Approved by castaway
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found