If clause in perl

HI friends ,

I am very new to perl .please dont mind if i ask silly questions.

I seee below code in one sript

 
if ( exists $ENV{FMTWRP_TMP_DIR} and $ENV{FMTWRP_TMP_DIR} ) {
  $tdir = $ENV{FMTWRP_TMP_DIR};
}

whats does this mean .

I am very confused about the if clauses in perl

can anyone please give oneline explanation what the belwo code snippets does

 
 
if ( $OSType =~ "SunOS" )
if ( @ARGV < 2 )
if ($background)
if (@ARGV)
if (index($primary_src,"none") == 0)
chomp( $processor = `uname -p` );
if ( !$restart )
if ( !$my_group
  || !$my_application
  || !$my_environment
  || !$my_ftpaccount
  || !$host
  || !$my_userid
  || !$my_whoami )
 
if ( ( -e $CYBERSDK_NEW ) && ( -e $my_credfilename ) )
$ok = open( CTRL_FILE, $ctrl_file ); if ( !($ok) )
 
while (<CTRL_FILE>) {
  chomp $_;
 
if ( exists $ENV{FMTWRP_TMP_DIR} and $ENV{FMTWRP_TMP_DIR} )
# Check if there exists value in hash %ENV referred by key "FMTWRP_TMP_DIR"

if ( $OSType =~ "SunOS" )
# Check if variable $OSType contains string "SunOS"

if ( @ARGV < 2 )
# Check if the number of arguments passed to perl program is less than 2

if ($background)
# Check if $background is true (or anything other than 0 or not null)

if (@ARGV)
# Check if arguments are passed to perl program ( equivalent of if(@ARGV > 0) )

if (index($primary_src,"none") == 0)
# Check if value in var $primary_src starts with string "none"

chomp( $processor = `uname -p` );
# Remove the new-line character at the end of string referred by variable $processor

if ( !$restart )
# Condition succeeds if $restart is false (or is null), fails if $restart is true (or contains some value).

if ( !$my_group
  || !$my_application
  || !$my_environment
  || !$my_ftpaccount
  || !$host
  || !$my_userid
  || !$my_whoami )
# Condition succeeds if any one of the variable is false (or is null), fails if all are true (or all variables contain some value).
 
if ( ( -e $CYBERSDK_NEW ) && ( -e $my_credfilename ) )
# Check if files referred by $CYBERSDK_NEW and $my_credfilename exist

$ok = open( CTRL_FILE, $ctrl_file ); if ( !($ok) )
# If $ok is false (or 0 or null), then open file referred by $ctrl_file into filehandle CTRL_FILE and store the value returned by open into $ok.
 
while (<CTRL_FILE>) {
  chomp $_;
# Read file referred by filehandle CTRL_FILE line by line and remove the new-line character (if present) at the end of each line
 
1 Like