perl -Calling the Subroutine Only if the condition is met

Hello All,

I am in the process of learning perl.I have a perl script and based on the arguments passed it would the appropriate subroutine that is defined in the script.

Now, I need to check a value that is defined in the Environment variables and should call the subroutine only if the condition is met.

#!/sw/bin/perl
$APPS = $ENV{'APPS'}
$SHELLDIR = "$APPS/shell";
foreach (@ARGV) {
    tr/a-z/A-Z/;                           # all upper case
    /COB=(.*)/ && ($DAM{'COB'} = $1);
    /^CREATE$/ && &create_Files;
    /^CREATE_ONLY$/ && &create_Files;
    /^TRANSMIT$/ && &transmit_files; ## I need to call the subroutine only if the $APPS value is /prod_application
    /^LOAD$/ && &load_dam_file;
    /^DOWNLOAD_FILE$/ && &load_measure;
    /^RECONCILE$/ && &run_command;
    /^LOAD_TIME_SERIES$/ && &load_time_series;
    /^SOON$/ && &soon_load_file;
    /^GW$/ && &gw;
}
exit;
sub transmit_files {
        system("cat $APPS/comb/send_file.ftp >> $APPS/comb/send_to_est.ftp");
    system("$SHELLDIR/send_files_to_est.sh");
    system("$SHELLDIR/move_file.pl");
}

Could someone please let me know how this can done in a simple way.

Your time and replies are greatly appreciated.

Cheers,

&transmit_files if $ENV{APPS} eq "/prod_application";
1 Like