Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

LWP::Simple? Prototype mismatch?

by George_Sherston (Vicar)
on May 16, 2005 at 13:05 UTC ( #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 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 ''; 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 (Parson) 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;
    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?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2016-10-24 23:21 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (311 votes). Check out past polls.