How can I call one Perl script from another?

If you would like to make a call to, or reference, a Perl script from within a different Perl script, you can accomplish this a system(), exec() or the backtick operator to the path for Perl. For example:

Or store output to array:

How to call perl or php script from HTML file?

Easiest way to do this is call php/perl script as javascript. Since javascript is client side stuff, php or perl script need to writeback output using javascript commands only. This is useful if you have lots of HTML files and would like to do some server side processing. For example Tips & Tricks section on our site has lots of html pages which uses code as follows:

Above code generates recent post posted in blog. Main advantage of this technique is simple, you can use it from HTML file and your javacode is also hidden (although other better ways exists to do this).

(A) An example of PERL, create file called as follows and put into your cgi-bin directory:

Add following line to your HTML code (replace with your real domain name):

(B) An example of PHP, create file called html.php as follows and put into your webserver directory:

Add following line to your HTML code (replace with your real domain name):

PHP code is bit easier to use as compare to PERL.

How to redirect url with perl script

It is common scenario when you need to tell the browser to redirect or look elsewhere for a page because you don’t want to produce a document yourself.

For example should redirect to a page/url

Here is perl code to redirect web page to

However this code misses the functionality to get URL as input, this can be easily done using standard CGI module. Please see script code.

i) Just download the rd.tar.gz script (click on download) or use wget command at shell prompt:
$ wget

ii) Copy script to your cgi-bin directory or directory where perl script execution allowed
iii) Suppose your domain name is and you put this script in directory called cgi-bin then to execute this script simply type or even ftp url