|
|
OverviewDistiguish the execution code based on the script name even though the same script. For example, there is a normal.cgi. And symbolic link it to ssimode.cgi. Then when the script is called from ssimode.cgi, execute the SSI code provided in the script.
Flow
A sample code
use File::Basename;
my $script = basename($0);
if ($script eq 'ssimode.cgi'){
&ssimode;
else {
&normalmode;
}
Description of the codeuse File::Basename; Load File::Basename; my $script = basename($0); When the perl command is executed, $0 contains the script name itself. By using basename method, it extracts command name only. i.e. exclude the path name. As a result, $script will have the script name only.
if ($script eq 'ssimode.cgi'){
&ssimode;
else {
&normalmode;
}
If $script is ssimode.cgi, execute &ssimode. Otherwise, execute &normalmode. |