Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please have a look at this code ........

Status
Not open for further replies.

maskman0

Programmer
Jul 24, 2007
9
US
I have a package:

package MAIN::Config;

it has the following functions in it :

sub new {
-- *** This function returns the o/p as follows :
GLOBAL REQ_SUBID = 0000000000000001
DATABASE DBUSER = sit
PATH CONFIG_DATA_PATH = ./data/
...etc
}
sub getValue(\%) {
my $this = shift;
my %fields = @_;
return $this->{VALUES}{GLOBAL}{$fields{KEY}} unless $this->{VALUES}{$fields{COMPONENT}}{$fields{KEY}};
}
----------------------------------------------
Please can you help me by telling me what the getValue function present in the MAIN::Config package does. When it is called in Line 3 in the main perl script :

Line 1) my $cfg = MAIN::Config->new(); # the o/p of the new() is as mentioned above.***
Line 2) $req_subscriber_id = $cfg->getValue(COMPONENT=>"",KEY=>"REQ_SUBID") || 000000000000001;
Line 3) $dbuser = $cfg->getValue(COMPONENT=>"DATABASE", KEY=>"DBUSER");
......
 
It looks as if it will return the string 'sit'... difficult to say without seeing all of the code, and difficult to say then as well. This type of code is not really self-documenting...

Mike

When working on any project the value of other people is exactly that - they are other people, with views that don't necessarily match yours. This mismatch, between their views and the view you've been contentedly assuming is right, is where that value lies.
 
Sorry Line three is does not have a DATABASE in it ....it is as follows:
Line 3) $dbuser = $cfg->getValue(COMPONENT=>"", KEY=>"DBUSER");
......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top