Click here to get back home

Problem using use CGI and LWP modules together

 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
Problem using use CGI and LWP modules together Nick Wedd 10-11-2007
Posted by Nick Wedd on October 11, 2007, 11:12 am
Please log in for more thread options
I am trying to develop a script to run on a web server. It uses the
modules
GD to do stuff with images
CGI to get the parameters from the URI
LWP to fetch stuff from the web

If my program begins
#!/usr/local/bin/perl
use strict;
use GD;
use GD::Text;
use CGI qw(:standard);
use LWP::Simple;
I get the error message
Prototype mismatch: sub main::head: none vs ($) at s4pngu.pl line 6
and if I change the order of the last two lines quoted above,
#!/usr/local/bin/perl
use strict;
use GD;
use GD::Text;
use LWP::Simple;
use CGI qw(:standard);
I get the error message
Prototype mismatch: sub main::head ($) vs none at
/usr/local/lib/perl5/5.8.8/CGI.pm line 305.

Removing the GD lines does not change this.

My guess is that the LWP and CGI modules are incompatible somehow. Am I
right? Or am I invoking them wrong? Is there a recommended solution?

Nick
--
Nick Wedd nick@maproom.co.uk

Posted by Gunnar Hjalmarsson on October 11, 2007, 12:02 pm
Please log in for more thread options
Nick Wedd wrote:
> I am trying to develop a script to run on a web server. It uses the
> modules
> GD to do stuff with images
> CGI to get the parameters from the URI
> LWP to fetch stuff from the web
>
> If my program begins
> #!/usr/local/bin/perl
> use strict;
> use GD;
> use GD::Text;
> use CGI qw(:standard);
> use LWP::Simple;
> I get the error message
> Prototype mismatch: sub main::head: none vs ($) at s4pngu.pl line 6
> and if I change the order of the last two lines quoted above,
> #!/usr/local/bin/perl
> use strict;
> use GD;
> use GD::Text;
> use LWP::Simple;
> use CGI qw(:standard);
> I get the error message
> Prototype mismatch: sub main::head ($) vs none at
> /usr/local/lib/perl5/5.8.8/CGI.pm line 305.
>
> Removing the GD lines does not change this.
>
> My guess is that the LWP and CGI modules are incompatible somehow. Am I
> right?

Well, there seems to be a conflicting symbol 'head' that is imported by
both LWP::Simple and CGI. Since you are using CGI only to get the CGI
parameters, one way to solve the problem is to exchange

use CGI qw(:standard);

for

use CGI qw(:cgi);

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Nick Wedd on October 11, 2007, 3:49 pm
Please log in for more thread options
>Nick Wedd wrote:
>> I am trying to develop a script to run on a web server. It uses the
>> modules
>> GD to do stuff with images
>> CGI to get the parameters from the URI
>> LWP to fetch stuff from the web
>> If my program begins
>> #!/usr/local/bin/perl
>> use strict;
>> use GD;
>> use GD::Text;
>> use CGI qw(:standard);
>> use LWP::Simple;
>> I get the error message
>> Prototype mismatch: sub main::head: none vs ($) at s4pngu.pl line 6
>> and if I change the order of the last two lines quoted above,
>> #!/usr/local/bin/perl
>> use strict;
>> use GD;
>> use GD::Text;
>> use LWP::Simple;
>> use CGI qw(:standard);
>> I get the error message
>> Prototype mismatch: sub main::head ($) vs none at
>> /usr/local/lib/perl5/5.8.8/CGI.pm line 305.
>> Removing the GD lines does not change this.
>> My guess is that the LWP and CGI modules are incompatible somehow.
>>Am I
>> right?
>
>Well, there seems to be a conflicting symbol 'head' that is imported by
>both LWP::Simple and CGI. Since you are using CGI only to get the CGI
>parameters, one way to solve the problem is to exchange
>
> use CGI qw(:standard);
>
>for
>
> use CGI qw(:cgi);
>

Many thanks - that works.

Nick
--
Nick Wedd nick@maproom.co.uk

Posted by Jim Gibson on October 11, 2007, 12:30 pm
Please log in for more thread options

> I am trying to develop a script to run on a web server. It uses the
> modules
> GD to do stuff with images
> CGI to get the parameters from the URI
> LWP to fetch stuff from the web
>
> If my program begins
> #!/usr/local/bin/perl
> use strict;
> use GD;
> use GD::Text;
> use CGI qw(:standard);
> use LWP::Simple;
> I get the error message
> Prototype mismatch: sub main::head: none vs ($) at s4pngu.pl line 6


>
> My guess is that the LWP and CGI modules are incompatible somehow. Am I
> right? Or am I invoking them wrong? Is there a recommended solution?


It does look like a name clash. I am able to reproduce this same error
on my system (perl 5.8.8).

You can use the OO features of CGI and avoid importing subroutines from
the module into your main:: namespace, provided you are comfortable
with the OO method of programming for CGI:

use CGI;
use LWP::Simple;

You will then have to define a CGI object and use method calls instead
of simple function calls.

Note that the following also demonstrates the error:

use CGI qw(head);
use LWP::Simple;

which really does indicate a 'head' clash.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Similar ThreadsPosted
Problem with installing modules November 24, 2006, 6:15 pm
Problem installing certain PERL modules October 15, 2004, 4:47 am
Installation problem - Net-SNMP Perl Modules on cygwin March 1, 2005, 1:52 am
GD modules September 1, 2004, 8:20 am
Perl PDF modules - help please August 11, 2004, 2:31 pm
installing modules? September 29, 2005, 1:52 pm
Need new maintainers for my modules January 8, 2005, 7:24 am
3rd party modules March 23, 2005, 4:56 pm
Installing modules August 5, 2005, 8:32 pm
Captcha Modules August 15, 2005, 5:35 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap