Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http-equiv syntax using CGI.pm

Status
Not open for further replies.

RPrinceton

Programmer
Jan 8, 2003
86
0
0
US
Hi Everyone,
The following HTML snippet was produced by Microsoft Frontpage:

<HEAD>
<META http-equiv="Content-Language" content="en-us">
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
</HEAD>

I need to generate the same coding using CGI.pm. What is the correct syntax for this. Please advise. Thx in advance.
Regards,
Randall Princeton
 
print $q->"<HEAD>\n<META http-equiv=\"Content-Language\" content=\"en-us\">\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n</HEAD>\n";

would do it
--Paul

cigless ...
 
Bear in mind that those http-equiv meta tags are saying "This is information that should be in the HTTP header, but isn't", usually used when you aren't able to change the headers sent with static pages (e.g. when using shared hosting).

With a CGI script, you send the headers yourself. You should already be sending the text/html content type, often done like this:
Code:
print "Content-type: text/html\n\n";
but maybe like this:
Code:
print $q->header(-type=>'text/html');

All you have to do is change whichever you've got to:
Code:
print $q->header(-type=>'text/html',
                 -charset='windows-1252',
                 -"Content-Language"='en-us');
In addition, it may be worth including the language parameter when opening your HTML document:
Code:
print $q->start_html(-lang=>'en-us');
Though as Paul points out, en-us is the default value anyway.

See for more about generating headers with CGI.pm

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
ChrisHunt
I have taken your 3rd example where you state "All you have to do is change whichever you've got to:" Below is what I receive when using this example.

print $mvHTML->header(-type => 'text/html',
-charset=>'windows-1252',
-"Content-Language"=>'en-us');
Error received:
Can't modify negation (-) in scalar assignment at DispSch.pl line 198, near "'windows-1252',"
Execution of DispSch.pl aborted due to compilation errors.


I then changed it to what follows, essentially placing a '>'
symbol after the '=' symbol. This allowed the page to display but it does not generate what I need as mentioned in the post.

print $mvHTML->header(-type => 'text/html',
-charset=>'windows-1252',
-"Content-Language"=>'en-us');

Here is what is contained in the page:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<html xmlns=" lang="en-US" xml:lang="en-US"><head>
</head><body>

Any ideas? Please advise. Thx in advance.
Regards,
Randall Princeton
 
You won't see it in the document, my point is that it doesn't need to be if you send the information in the actual http headers. If your page is on the internet, you can use the online tool at to view the headers that are being sent.

If it's not publically accessible, there are extensions you can download for Firefox that will enable you to see them.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top