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:

system("/usr/bin/perl /path/to/my_script.pl ");

Or store output to array:

@myarray = `/usr/bin/perl mysecondperlscript.pl`;

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/:

#!/usr/bin/perl

use strict;

use warnings;

my $url = "http://blogs.cyberciti.biz/hm/";

print "Location: $url\n\n";

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/