perl -Calling the Subroutine Only if the condition is met


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl -Calling the Subroutine Only if the condition is met
# 1  
Old 02-01-2013
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.

Code:
#!/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,
# 2  
Old 02-01-2013
Code:
&transmit_files if $ENV{APPS} eq "/prod_application";

This User Gave Thanks to radoulov For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk - print when condition is met

I have a file.txt containing the following: Query= HWI-ST863:386:C5Y8UACXX:3:2302:16454:89688 1:N:0:ACACGAAT Length=100 Score E Sequences producing significant alignments: (Bits) Value ... (2 Replies)
Discussion started by: tons92
2 Replies

2. Shell Programming and Scripting

Getting the records once condition met

Hi All, Seeking for your assistance to get the records once the $2 met the condition. Ex. file 1.txt 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 123232,11-Aug-2015 08:33:37 PM,4234324,1321432,34364 Output: 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 What i did... (5 Replies)
Discussion started by: znesotomayor
5 Replies

3. Shell Programming and Scripting

Delete if condition met in a column

i have a table like this: id, senderNumber, blacklist ----------------------------- 1 0835636326 Y 2 0373562343 Y 3 0273646833 Y and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script I... (9 Replies)
Discussion started by: jazzyzha
9 Replies

4. Shell Programming and Scripting

Calling perl subroutine from shell script (sh)

Hi, ive a perl script, where it has a subroutine clear() in it, and i've one shell script which runs in background, from that shell script i wanted to call subroutine which is in perl script, that's perl script is not module, just simple script. Eg: perl script <test> #!... (4 Replies)
Discussion started by: asarunkumar
4 Replies

5. UNIX for Advanced & Expert Users

While loop only if a condition is met

All, I wrote the following section of code (which logically in PHP would of worked): tmpPATH=${1} tmpTAG=${2} if then while read tmpTAG tmpPATH do fi echo $tmpTAG echo $tmpPATH if then done < ./config.cfg fi (4 Replies)
Discussion started by: Cranie
4 Replies

6. Shell Programming and Scripting

calling perl subroutine from perl expect module

All, Is it possible to call a subroutine from the perl expect module after logging to a system that is within the same program. My situation is I need to run a logic inside a machine that I'm logging in using the expect module, the logic is also available in the same expect program. Thanks,... (5 Replies)
Discussion started by: arun_maffy
5 Replies

7. Shell Programming and Scripting

do nothing if condition is not met but not exit

Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit.... #!/bin/ksh ########################### ########################### # Set name of the listener, this... (2 Replies)
Discussion started by: abdul.irfan2
2 Replies

8. Shell Programming and Scripting

How to break a loop if condition is met

I am having trouble figuring this code I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text Here is what I have written but it isn't working while true f=`grep 'END OF STATUS REPORT' filename` do if ... (9 Replies)
Discussion started by: Issemael
9 Replies

9. Shell Programming and Scripting

Calling a subroutine with arguments

Hello, I am having problem calling a subroutine with arguments, can any help? is the approach I am using correct? main() { # This is just a subset of the code #$b & $lnum is already define in this section of the code checkboard $b $lnum } checkboards() { ln=$lnum... (2 Replies)
Discussion started by: jermaine4ever
2 Replies

10. Shell Programming and Scripting

Problem in subroutine calling

Hi, we can call the subroutines using two ways .... 1) calling subroutine name preceeded by & symbol. 2)Another one is without &symbol.... what is the diff b/w these two.... ############################ #usr/bin/perl fun; sub fun { print "hi this is from perl\n"; }... (1 Reply)
Discussion started by: sarwan
1 Replies
Login or Register to Ask a Question