Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:27:07+00:00 2026-06-02T08:27:07+00:00

Using the Perl code #!/usr/bin/perl use strict; use warnings; use CGI :all; use Encode;

  • 0

Using the Perl code

#!/usr/bin/perl

use strict;
use warnings;
use CGI ":all";
use Encode;

my $cgi = new CGI;

$cgi->charset('utf-8');

print $cgi->header(-type    => 'text/html',
                   -charset => 'utf-8');

print $cgi->start_html(-title => 'Test',
                       -head  => meta({-http_equiv => 'Content-Type',
                                       -content => 'text/html; charset=utf-8'}));
my $text = 'test'; # for now

Encode::from_to($text, 'latin1', 'utf8');

print $cgi->p($text);
print $cgi->end_html;

I am getting the following output:

Content-Type: text/html; charset=utf-8

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>test</p>
</body>

And I don’t know why

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

is in the output and I don’t know how to get rid of it.

All suggestions will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:27:08+00:00Added an answer on June 2, 2026 at 8:27 am

    add an -encoding parameter to start_html and don’t build the meta element by hand. (despite what the CGI docs suggest you do).

    print $cgi->start_html(-title => "Test", -encoding => "utf-8")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which works. #!/usr/bin/perl use warnings; use strict; use Net::LDAP; use
Given this code: #!/usr/bin/perl -w use strict; use warnings; sub foo { return wantarray
I have a problem passing a string argument using Perl. The following code #!/usr/bin/perl
I want to profile my Perl code by using Devel::DProf . when I am
Is it possible to save some Perl code in a database, retrieve it using
Per http://perldoc.perl.org/CGI.html to make meta tags, the following example is given: print start_html(-head=>meta({-http_equiv =>
I have tried using the following Perl code, but the worksheet does not copy
I am using the Following Perl code to parse an array in JSON, using
Using Perl, how do I check if a particular Windows process is running or
I am using Perl to do text processing with regex. I have no control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.