473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to run .pl files in a browser? PERL

135 100+
I've tried to rename the perl file from .pl to HTML and this did not work. Currently I run my .pl files from the command prompt, how do I run them from a browser.

Please see the follow PERL code I'm trying to run in a browser:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. %pages = (
  4.     "fred" => "http://www.cgi101.com/~fred",
  5.     "Wilma" => "http://www.cgi101.com/~wilma",
  6. );
  7.  
  8. print "Content-type:text/html\n\n";
  9. print <<EndHdr;
  10.  
  11. <html><head><title>URL List</title></head>
  12. <body bgcolour="#ffffff">
  13.  
  14. <p>
  15. <h2>URL List</h2>
  16. <ul>
  17. EndHdr
  18.  
  19. foreach $key (keys %pages) {
  20.     print "<li><a href=\"$pages{$key}\">$key</a>\n";
  21. }
  22.  
  23. print <<EndFooter;
  24. </ul>
  25. <p>
  26. </body>
  27. </html>
  28. EndFooter
Sep 6 '07 #1
3 15942
KevinADC
4,059 Expert 2GB
You need to install and setup an http server on your local PC to run CGI scripts. apache is free and pretty easy to get setup. Ask in the apache forum how to go about doing it.

Browsers run HTML code, know what to do with javascript and CSS, but perl is just text to a browser. Could you imagine if browsers could run perl scripts that easily? Everyones computers would be hacked by the end of the day.
Sep 6 '07 #2
patelxxx
135 100+
Kevin,

I have setup Apache and is running, however when I run the code as a HTML file it gives me the following results, whereas I'm expecting the result to be same as the command prompt when I run it (perl variablehash.pl).

RESULTS in .html:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. %pages = (
  4.     "fred" => "http://www.cgi101.com/~fred",
  5.     "Wilma" => "http://www.cgi101.com/~wilma",
  6. );
  7.  
  8. print "Content-type:text/html\n\n";
  9.  
  10. print <<EndHdr;
  11.  
  12. <html><head><title>URL List</title></head>
  13. <body bgcolour="#ffffff">
  14.  
  15. <p>
  16. <h2>URL List</h2>
  17. <ul>
  18. EndHdr
  19.  
  20. foreach $key (keys %pages) {
  21.     print "$key\n";
  22. }
  23.  
  24. print <<EndFooter;
  25. </ul>
  26. <p>
  27. </body>
  28. </html>
  29. EndFooter
  30.  
Sep 7 '07 #3
KevinADC
4,059 Expert 2GB
You're confused. You don't embed perl in html. That is not the way to run perl base dCGI scripts. You write perl programs and, name them with .pl or .cgi extensions ( for now anyway), put them in the cgi-bin, and run them form there. So set up the cgi-bin to run executables and start putting your cgi scripts in the cgi-bin.
Sep 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: daniel kaplan | last post by:
i am a newbie PERL programmer, oldtime C guy here....anyway, i am starting some PERL scripts on a shared LINUX server. i cannot store my MySQL login parametrs in the apache config, since it is...
6
by: nmadpl | last post by:
Hi, I am very new to Perl scripting and I am trying to modify XML files thro' Perl scipts. I would like to know how can I grab a piece of information (say 3 lines) from one xml file and write it...
2
by: Gary42103 | last post by:
Hi I need Perl Script to do Data Parsing using existing data files. I have my existing data files in the following directory: Directory Name: workfs/ams Data File Names: 20070504.dat,...
0
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
does any 1 know where i can get a ready files browser in vb.net? which i can use to browse folder and files on my server? thnaks i nadvnace Peleg
5
by: Davo1977 | last post by:
Analysing text files to obtain statistics on their content You are to write a Perl program that analyses text files to obtain statistics on their content. The program should operate as follows: ...
3
by: djia002 | last post by:
Hello everyone, I am new to Perl, and stuck with file uploading issue. My Html is this, <form enctype="multipart/form-data" method=post action="/cgi-bin/upload/mfile.pl"> <input type=file...
3
by: vibhakhushi | last post by:
How to compare two files in perl. I have two files as shown below. First XML File <Data> <indep voltage> +1.20000000000e+01 </indep> <indep current> +5.08474576271e-04
3
by: rajesh dogra | last post by:
Hi All, i am trying to move a bunch of files in a newly created directory: here is what i am trying to do. : i read my source dir. : i search for a file which has the folder name information...
3
by: raghusln | last post by:
How to call sequence of batch files from perl script
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.