Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

What did i do to CGI.pm?

by vaevictus (Pilgrim)
on Jan 05, 2001 at 04:06 UTC ( #49920=perlquestion: print w/replies, xml ) Need Help??

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

I found this through doing the wrong method for adding css. Can anyone duplicate?
#!/usr/bin/perl -wT use strict; use CGI ; my $q= new CGI; print $q->header; print $q->start_html(-head=>Link({-rel=>'next', -href=>'http://www.capricorn.com/s2.html'} +)); print $q->h1 ("Welcome to Vaevictus.net"), $q->p( "not much here yet" ), $q->end_html;
That produces strangenesses... To the browser:
HTTP/1.1 200 OK Date: Thu, 04 Jan 2001 23:01:35 GMT Server: Apache/1.3 +.12 (Unix) mod_perl/1.24 PHP/4.0.2 mod_ssl/2.6.6 OpenSSL/0.9.6 Connection: close Content-Type: text/html; charset=iso-8 +859-1 OK The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, vae@deathstar and inform them + of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error + log.
and to the errorlog:
[Thu Jan 4 17:01:35 2001] [error] Undefined subroutine &Apache::ROOTw +ww_2evaevictus_2enet::index_2epl::Link called at /home/vae/public_htm +l/index.pl line 10.
shouldn't the example from the perldoc work?

Replies are listed 'Best First'.
Re: What did i do to CGI.pm?
by merlyn (Sage) on Jan 05, 2001 at 04:27 UTC
    It's saying you don't have Link defined, and since you didn't import any symbols, that makes sense.

    Either use $q->Link, or change your use CGI... line.

    -- Randal L. Schwartz, Perl hacker

      Of Course you're right. I didn't see it. :) If only *I* had a nickel for everytime that Merlyn had the right idea.
Re: What did i do to CGI.pm?
by Fastolfe (Vicar) on Jan 05, 2001 at 04:14 UTC
    It looks like Apache is running your script under mod_perl. You can probably get around this by placing your script in the server's cgi-bin directory or perhaps just changing its extension to ".cgi". Looks like your Apache server is set up to treat any file with a .pl extension as a mod_perl file, which isn't a straightforward CGI script.

    Update: As merlyn notes, the root cause is with the use of Link, but the reason that error seems obfuscated and the method of relaying the message is due to the fact that mod_perl (well, Apache::Registry) is taking over execution of the script. In all likelyhood, so long as caveats addressed in documents like http://perl.apache.org/dist/mod_perl_traps.html are observed, this script should still run OK.

      You're saying the mod_perl isn't CGI.pm compatible?
        No, I'm saying plain-vanilla CGI.pm scripts are not always mod_perl-compatible, but they can be made to be. See http://perl.apache.org/dist/mod_perl_traps.html. Your precise problem is described and explained about 1/3 of the way down under "Perl Modules and Extensions".
      changing the extension didn't affect the output, except for the logfile which refers to index.cgi now...
        Check your web server's configuration and see if you can figure out what isn't being treated as a mod_perl file. You may have to just put this in your server's /cgi-bin/ directory, or modify your public_html environment slightly with a .htaccess file that excludes your directory (or certain file extensions) from classifying these files as mod_perl files.
Re: What did i do to CGI.pm?
by damian1301 (Curate) on Jan 05, 2001 at 04:39 UTC
    This should work...
    #!/usr/bin/perl use CGI qw/link/; $cgi = new CGI; print $cgi->link({rel=>'stylesheet', href=>'http://www.capricorn.com/s2.css'});
    Best of luck!

    Wanna be perl hacker.
    Dave AKA damian
Re: What did i do to CGI.pm?
by vaevictus (Pilgrim) on Jan 05, 2001 at 04:44 UTC
    Better mention that I removed the hitches to mod_perl and still had the issues... now errors as
    Undefined subroutine &main::Link called at /home/vae/public_html/index +.cgi line 10.
      This:
      use CGI; my $q = CGI->new; print $q->start_html( -title => "Some Title", -style => { src => '../style.css', type => 'text/css' } );
      Produces:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head><title>S +ome Title</title> <link rel="stylesheet" type="text/css" href="../style.css"> </head><body>
      I believe you were looking for how to include a proper CSS link? That should do it. I'm using CGI.pm version 2.74.

      Gosh, I love CGI.pm :)

      Cheers,
      Ovid

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2022-05-20 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?