Sponsored Content
Special Forums UNIX and Linux Applications Infrastructure Monitoring diffrence between method call and function call in perl Post 302302002 by KevinADC on Sunday 29th of March 2009 06:02:06 PM
Old 03-29-2009
Just guessing....

After cleaning up this sloppy code to make it readable you can see that $result[0] has the chance of never being defined:

Code:
rrequire "/Mehran/DSGateEngineLib/general.pl";
use strict;
sub System_Status_Main_Service_Status_Intrusion_Prevention {
   my %idpstatus;
   my @result;
   &General_ReadHash("/var/dsg/idp/settings",\%idpstatus);
   #print $idpstatus{'ENABLE_IPS'};
   if( $idpstatus{'ENABLE_IPS'} ){
      $result[0] = 'on';
      if( $idpstatus{'POLICY'} eq "default" ){
         $result[1] = "Default";
      }
      elsif ($idpstatus{'POLICY'} eq "alert"){
         $result[1] = "Alert";
      }
      else {
         $result[1] = "Action";
      }
   }
   elsif ($idpstatus{'ENABLE_IPS'} eq 'off'){
      $result[0] = 'off';
   }
   print $result[0]
}
&System_Status_Main_Service_Status_Intrusion_Prevention();

You should add a fall-through condition to the end of the if/elsif block to make sure $result[0] will always be defined:

Code:
require "/Mehran/DSGateEngineLib/general.pl";
use strict;
sub System_Status_Main_Service_Status_Intrusion_Prevention {
   my %idpstatus;
   my @result;
   &General_ReadHash("/var/dsg/idp/settings",\%idpstatus);
   #print $idpstatus{'ENABLE_IPS'};
   if( $idpstatus{'ENABLE_IPS'} ){
      $result[0] = 'on';
      if( $idpstatus{'POLICY'} eq "default" ){
         $result[1] = "Default";
      }
      elsif ($idpstatus{'POLICY'} eq "alert"){
         $result[1] = "Alert";
      }
      else {
         $result[1] = "Action";
      }
   }
   elsif ($idpstatus{'ENABLE_IPS'} eq 'off'){
      $result[0] = 'off';
   }
   else { #<-- fall-through condition 
      $result[0] = 'unknown status';
   }
   print $result[0]
}
&System_Status_Main_Service_Status_Intrusion_Prevention();


Last edited by KevinADC; 03-29-2009 at 07:07 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl function call tracking

Assuming the following code sub foo { dosomething {...} else { foo } is the number of times foo has been called kept track of internally and how could I access that count? (1 Reply)
Discussion started by: thumper
1 Replies

2. Shell Programming and Scripting

function call

can I call a function in bash script just as in C++ while do function() done function() thanks, Steffen (3 Replies)
Discussion started by: forever_49ers
3 Replies

3. Shell Programming and Scripting

Recursive method call getting terminated ???

Hello people, Need help !!! What am I doing wrong here ? I am writing a function to recursively list the files under a folder and it's sub-folders. Problem is once it list the files under the innermost folder, it terminates. What do I need to do so that it returns and list files under the... (3 Replies)
Discussion started by: tipsy
3 Replies

4. Programming

Help with a function call

Hi, Can anyone help me figure out the problem I'm having with a function call? I have a header file, which sets an enum: typedef enum {INFO, WARNING, FATAL} Levels; int log_event (Levels, char *fmt, ...); ..then the function is called this way: log_event(INFO, "Message text"); ... (6 Replies)
Discussion started by: Stevhp
6 Replies

5. Shell Programming and Scripting

call function

I have a function check_ok in my abc.sh. which return me 1 or 0 . I want to call this fuction through other shell script. this shell also send two parameter to calling function. Can you please tell me how. I am very new in unix. #!/bin/bash date_equal() { sqlplus -silent... (4 Replies)
Discussion started by: Jamil Qadir
4 Replies

6. Shell Programming and Scripting

function call

hi, can any one help me to correct this function call. awk -F "," '{ {first=$1; sec=$2; tro=$3;quat=$4 } if (tro == "") { $3 = search "$file2" "$first" "$file3" {print $1","$2","$3","$4} } else {print $1","$2","$3 $4}}' $file1 > $file search () { (2 Replies)
Discussion started by: kamel.seg
2 Replies

7. Shell Programming and Scripting

Function Call

Hi, I have a string corresponding to a function. How I can call that function without if statement? Thanks in advance. (4 Replies)
Discussion started by: Zaxon
4 Replies

8. Shell Programming and Scripting

Function call

Hi foiks i am unable to find what is wrong in my code mu functionality is to exit from shell when i give 99 but it is not calling function ext Could you please correct me. read option if ; then ext else echo "out" fi function ext { echo "tested 99 and exit... (12 Replies)
Discussion started by: kojo
12 Replies

9. Emergency UNIX and Linux Support

Perl error: Can't call method "value" on an undefined value

Hi, I am running a perl script to automate a process and I keep running into a error can't find the "value" Can't call method "value" on an undefined value at process_file.pl line 44. file is CVS cell is ifdfdxrfmp.ksh Here is the script I have also attached it as well: ... (2 Replies)
Discussion started by: vpundit
2 Replies

10. Shell Programming and Scripting

How to Call a Function

Hi I have created a function in a Shell Script test.sh function fnTest() { echo "My first Method } I have called this function in my test.sh cat abc.txt | grep "test" echo " test" fnTest But while running the shell script i got the following error: ... (2 Replies)
Discussion started by: nanthagopal
2 Replies
Net::EPP::ResponseCodes(3pm)				User Contributed Perl Documentation			      Net::EPP::ResponseCodes(3pm)

NAME
Net::EPP::ResponseCodes - a module to export some constants that correspond to EPP response codes SYNOPSIS
use Net::EPP::ResponseCodes; use Net::EPP::Simple; use strict; my $epp = Net::EPP::Simple->new( host => 'epp.nic.tld', user => 'my-id', pass => 'my-password', ); my $result = $epp->domain_transfer_request('example.tld', 'foobar', 1); if ($result) { print "Transfer initiated OK "; } else { if ($Net::EPP::Simple::Code == OBJECT_PENDING_TRANSFER) { print "Error: domain is already pending transfer "; } elsif ($Net::EPP::Simple::Code == INVALID_AUTH_INFO) { print "Error: invalid authcode provided "; } elsif ($Net::EPP::Simple::Code == OBJECT_DOES_NOT_EXIST) { print "Error: domain not found "; } elsif ($Net::EPP::Simple::Code == STATUS_PROHIBITS_OP) { print "Error: domain cannot be transferred "; } else { print "Error code $Net::EPP::Simple::Code "; } } DESCRIPTION
EPP is the Extensible Provisioning Protocol. EPP (defined in RFC 4930) is an application layer client-server protocol for the provisioning and management of objects stored in a shared central repository. Specified in XML, the protocol defines generic object management operations and an extensible framework that maps protocol operations to objects. As of writing, its only well-developed application is the provisioning of Internet domain names, hosts, and related contact details. Every response sent to the client by an EPP server contains a "<result>" element that has a "code" attribute. This is a four-digit numeric code that describes the result of the request. This module exports a set of constants that provide handy mnemonics for each of the defined codes. EXPORTS
"Net::EPP::ResponseCodes" exports the following constants. The number in brackets is the integer value associated with the constant. Successful command completion responses(1nnn) OK(1000) OK_PENDING(1001) OK_NO_MESSAGES(1300) OK_MESSAGES(1301) OK_BYE(1500) Command error responses(2nnn) Protocol Syntax UNKNOWN_COMMAND(2011) SYNTAX_ERROR(2011) USE_ERROR(2011) MISSING_PARAM(2011) PARAM_RANGE_ERROR(2011) PARAM_SYNTAX_ERROR(2011) Implementation-specific Rules UNIMPLEMENTED_VERSION(2100) UNIMPLEMENTED_COMMAND(2101) UNIMPLEMENTED_OPTION(2102) UNIMPLEMENTED_EXTENSION(2103) BILLING_FAILURE(2104) NOT_RENEWABLE(2105) NOT_TRANSFERRABLE(2106) Security(22nn) AUTHENTICATION_ERROR(2200) AUTHORISATION_ERROR(2201) AUTHORIZATION_ERROR(2201) INVALID_AUTH_INFO(2202) Data Management(23nn) OBJECT_PENDING_TRANSFER(2300) OBJECT_NOT_PENDING_TRANSFER(2301) OBJECT_EXISTS(2302) OBJECT_DOES_NOT_EXIST(2303) STATUS_PROHIBITS_OP(2304) ASSOC_PROHIBITS_OP(2305) PARAM_POLICY_ERROR(2306) UNIMPLEMENTED_OBJECT_SERVICE(2307) DATA_MGMT_POLICY_VIOLATION(2308) Server System(24nn) COMMAND_FAILED(2400) Connection Management(25nn) COMMAND_FAILED_BYE(2500) AUTH_FAILED_BYE(2501) SESSION_LIMIT_EXCEEDED_BYE(2502) AUTHOR
CentralNic Ltd (<http://www.centralnic.com/>). COPYRIGHT
This module is (c) 2012 CentralNic Ltd. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
o Net::EPP::Client o Net::EPP::Frame o Net::EPP::Proxy o RFCs 4930 and RFC 4934, available from <http://www.ietf.org/>. o The CentralNic EPP site at <http://www.centralnic.com/resellers/epp>. perl v5.14.2 2012-04-23 Net::EPP::ResponseCodes(3pm)
All times are GMT -4. The time now is 06:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy