Problem using use CGI and LWP modules together
Problem using use CGI and LWP modules together
am 11.10.2007 17:12:38 von Nick Wedd
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
Re: Problem using use CGI and LWP modules together
am 11.10.2007 18:02:59 von Gunnar Hjalmarsson
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
Re: Problem using use CGI and LWP modules together
am 11.10.2007 18:30:19 von Jim Gibson
In article , 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
>
> 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
Re: Problem using use CGI and LWP modules together
am 11.10.2007 21:49:28 von Nick Wedd
In message <5n6vptFgj9hcU1@mid.individual.net>, Gunnar Hjalmarsson
writes
>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