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 8085485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:08:03+00:00 2026-06-05T18:08:03+00:00

I have run this Perl code: #!/usr/bin/perl print content-type: text/html \n\n; print Hello World.\n;

  • 0

I have run this Perl code:

#!/usr/bin/perl
print "content-type: text/html \n\n";
print "Hello World.\n";

I have tried it in two ways, first one is Testing your Perl installation, but when I run by this way, it has some troubles, it asks me to choose a program with which I can run it, but no running yet.

Second way is first script with Padre, the Perl IDE, but when I write Perl code and try to save it, it does not show me Perl file’s extension, so I can’t save it as Perl file, so what could I do?

  • 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-05T18:08:07+00:00Added an answer on June 5, 2026 at 6:08 pm

    Your code looks like you want a CGI program. CGI means that you call your program through a web browser and get a website back. While vstm’s comment was of course right for non-cgi programs, your example requires a little more stuff in order to work like that.

    You will need to install a web server. Take a look at xampp. It is simple to install and maintain and comes with a mysql as well as an apache installation. I recommend the lite version since that does not have all the overhead.

    Once you’ve installed it, you need to make some configuration so it can run your perl scripts. I take it you have already installed Active Perl. You then need to tweak the apache config.

    in c:\xampp\apache\conf\httpd.conf you need to find the line that says

    <Directory "C:/xampp/htdocs">
    

    and read the comments (marked with #). You have to add ExecCGI inside the <Directory> section. Do that for every directory you want perl scripts to be run. Then look for a line that says

    AddHandler cgi-script .cgi .pl .asp
    

    and make sure it is not commented out.

    Once you’re done, place your program in the c:\xampp\htdocs folder (cgi-bin should also work) and change the shebang-line (the first line with #!) to where you’ve installed Active Perl, e.g. C:\perl\bin\perl.exe. It tells apache what program it should use to execute the perl script.

    Also, add some more lines to your code:

    #!C:\perl\bin\perl.exe
    use strict;
    use warnings;
    use CGI;
    use CGI::Carp('fatalsToBrowser');
    print "Content-type: text/html \n\n";
    print "Hello World.\n";
    

    Now you need to run the apache web server. In the xampp installation dir there are several batch files that control apache and mysql. There’s also a xampp-control.exe. Run it. In the new window, click on the Start button next to Apache.

    In your browser, go to http://localhost/<yourscript.pl>. It should now say “Hello World!”.

    If it does not, make sure you’re not running Skype. It blocks your port 80 which the apache tries to run on. You need to change apache’s port to something else. Refer to this video.


    A few words on the changes in the code I made and what they do:

    • use strict; should always be in your code. It forces you to honor certain guidelines and to write better code. This might seem strange in a Hello World program, but please do it anyway.
    • use warnings; tells you about things that might go wrong. Warnings are not errors but rather perl being helpful about stuff you might not know yourself. Use it.
    • use CGI makes the program’s output go to the web server. You need that when you work with CGI programs.
    • print "Content-type: text/html \n\n"; is needed so the browser knows what to expect. In this case, an HTML website. It is called the HTTP-Header and contains a mime-type.
    • use CGI::Carp('fatalsToBrowser'); makes errors go to the browser. Without it, you’d never know about them unless you look in apache’s error log.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to run this perl5 program: #!/usr/bin/env perl use strict; use warnings; use
I have the following sample code #!/usr/bin/perl use strict; use warnings; my $b =
I have a piece of code like this (Perl file): print 9 + 16
I have the following code #!/usr/bin/perl use Tie::File; tie my @last_id, 'Tie::File', 'last_id.txt' or
I have tryed to run this code in my console: script/plugin install git://github.com/apotonick/cells.git ...but
I have a problem when I run this snippet of code on the emulator
I have a delphi 7 form: and my code: when I run this form
I have the code below. For some reason when I run this code it
I have updated my code to look like this. When I run it though
Has anyone run perl script given at http://oreilly.com/pub/h/974#code ? This is a famous one,

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.