CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Meaning of this Perl code.

 



sh.ajay12
User

Dec 11, 2013, 5:08 AM

Post #1 of 5 (1026 views)
Meaning of this Perl code. Can't Post

Hello Members,

Please tell me what is the meaning of this Perl code.

$URL=$ENV{"S_URL"} || "/";
$USERLEVEL=$ENV{"S_USERLEVEL"} || 0;
$USERNAME=$ENV{"S_USERNAME"} || "";
$LOGINNAME=$ENV{"S_LOGINNAME"} || "unknown";

$USERLEVEL=2 if ( $USERLEVEL==1 );

$THIRDLINE=$ENV{"S_THIRDLINE"} || 0;
$TECHMANAGER=$ENV{"S_TECHMANAGER"} || 0;

$DO=$ENV{"F_DO"} || "TOP_MENU";
$DO="TOP_MENU" if ( $DO =~ m/login/i );

I have checked they are not environment variables.

Thank you in Advance.


FishMonger
Veteran / Moderator

Dec 11, 2013, 6:15 AM

Post #2 of 5 (1019 views)
Re: [sh.ajay12] Meaning of this Perl code. [In reply to] Can't Post

Those are just simple var assignments that copy the value of some environment variables. If the environment var does not exist (or evaluates to false), a default value is used in the assignment.


sh.ajay12
User

Dec 11, 2013, 9:04 PM

Post #3 of 5 (1011 views)
Re: [FishMonger] Meaning of this Perl code. [In reply to] Can't Post

Hello FishMonger,

I have checked the Perl environments variables with a Perl code.

But I did not found the environment variables as in the above code.

SCRIPT_NAME = /cgi-dev/new.cgi
SERVER_NAME = opchs01blacksheep.rms.impss.com
SERVER_ADMIN = root@localhost
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_CONNECTION = Keep-Alive
REQUEST_METHOD = GET
HTTP_ACCEPT = image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
SCRIPT_FILENAME = /data-sdb1/www/cgi-dev/new.cgi
SERVER_SOFTWARE = Apache/2.2.3 (Red Hat)
QUERY_STRING =
REMOTE_PORT = 2164
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E)
SERVER_PORT = 80
SERVER_SIGNATURE =
Apache/2.2.3 (Red Hat) Server at opchs01blacksheep.rms.impss.com Port 80

HTTP_ACCEPT_LANGUAGE = en-gb
HTTP_COOKIE = IMPSS_opchs01blacksheep=941613063988373
REMOTE_ADDR = 62.239.22.20
SERVER_PROTOCOL = HTTP/1.1
PATH = /sbin:/usr/sbin:/bin:/usr/bin
REQUEST_URI = /cgi-dev/new.cgi
GATEWAY_INTERFACE = CGI/1.1
SERVER_ADDR = 193.113.127.139
DOCUMENT_ROOT = /data-sdb1/www/htdocs
HTTP_HOST = opchs01blacksheep.rms.impss.com
$0 is /data-sdb1/www/cgi-dev/new.cgi

above env variables i found.


Laurent_R
Veteran / Moderator

Dec 12, 2013, 1:22 AM

Post #4 of 5 (999 views)
Re: [sh.ajay12] Meaning of this Perl code. [In reply to] Can't Post

The %ENV hash is really the container of the environment variables. But, given the variables used in your Perl script, it could very well be that these variables are defined and exported in the shell script that launches your Perl program (or in another Perl program that launches the code that you are looking at).

We have a lot of such cases where I work: one shell script that wraps the whole application and launches a number of different Perl programs. Exporting environment variables from the shell script makes it possible to define some data paths, file names, some constants for the run (such as the dates to be used), etc. in one single place, i.e. the shell script, and and have all the Perl programs to use the same values for these variables.


sh.ajay12
User

Dec 12, 2013, 2:12 AM

Post #5 of 5 (997 views)
Re: [Laurent_R] Meaning of this Perl code. [In reply to] Can't Post

Hi Laurent_R,

Yes you told correct. I have checked the Perl script which is triggering this script has the variables defined.

Thank You for you valuable reply.
And Thank You to Fish Monger.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives