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 blogs.cyberciti.biz/hm 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 html.pl as follows and put into your cgi-bin directory:

Add following line to your HTML code (replace mydomain.com 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 mydomain.com 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 http://mydomain.com/rd.pl?url=http://blogs.mydomain.com should redirect to a page/url http://blogs.mydomain.com

Here is perl code to redirect web page to http://blogs.cyberciti.biz/hm/:

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

i) Just download the rd.tar.gz script (click on download) or use wget command at shell prompt:
$ wget https://www.cyberciti.biz/download/perl_scripting/cgi/rd.pl.tar.gz

ii) Copy rd.pl script to your cgi-bin directory or directory where perl script execution allowed
iii) Suppose your domain name is cyberciti.biz and you put this script in directory called cgi-bin then to execute this script simply type http://cyberciti.biz/cgi-bin/rd.pl?url=http://www.goole.com or even ftp url http://cyberciti.biz/cgi-bin/rd.pl?url=ftp://ftp.freebsd.org/