neversaint
neversaint

Reputation: 64074

How to include Meta tag through CGI.pm

I want to include the following HTML meta tag into a cgi script:

<meta name="googlebot" content="noindex,nofollow,noarchive,noodp,nosnippet" />

But why this doesn't print out the result?

use CGI;
print
    $query->start_html(-title =>'MyWeb',
       -meta => {
         -name =>'googlebot',
         -content =>'noindex,nofollow,noarchive,noodp,nosnippet'}
    ),p;

What's the correct way to do it?

Upvotes: 2

Views: 599

Answers (3)

勿绮语
勿绮语

Reputation: 9330

use strict; 
use warnings;  
use CGI;
my $query = CGI->new();
print
    $query->start_html(-title =>'MyWeb',
       -meta => {'googlebot' => 'noindex,nofollow,noarchive,noodp,nosnippet'}
    );

Upvotes: 3

Tudor Constantin
Tudor Constantin

Reputation: 26871

This works on my machine:

use CGI qw(start_html);
use strict;
use warnings;


print
    start_html(-title =>'MyWeb',
       -meta => {
         'googlebot' => 'noindex,nofollow,noarchive,noodp,nosnippet',
        }
    );

Upvotes: 1

Thilo
Thilo

Reputation: 262834

Works for me...

In your example, you did not initialize $query, could that be the problem?

use CGI;
use strict;
print
    CGI->start_html(-title =>'MyWeb',
       -meta => {
         -name =>'googlebot',
         -content =>'noindex,nofollow,noarchive,noodp,nosnippet'}
    );

Upvotes: 1

Related Questions