HI All ,
Below is a quite simple code , which reads data from a configuration file and loads it into hash.
The Hash loading is being done in the function load_profile_hash and accessed from the main function,
The configuration file is of the type
A=100
B=300
Code:
#!/usr/bin/perl use Data::Dumper;
#Execute the main function
my $profile_mapper_file="/tmp/varun/profile_map.txt";
sub load_profile_hash()
{
my %profile_mapping;
# Read the mapping file for loading the Hash
open(PROFILE_MAPPER, "<$profile_mapper_file") || die "I/O Success - Cannot process $profile_mapper_file file";
my %profile_mapping = map { chomp; split /=/ } <PROFILE_MAPPER>;
print Dumper(\%profile_mapping);
return (\%profile_mapping);
}
sub main()
{
my $profile_mapping_ref;
#load the CDB profile - ICC profile
$profile_mapping_ref=load_profile_hash();
print "@@@@\n";
print $$profile_mapping_ref{"A"};
print "@@@@\n";
}
main();
However , in the main function , the value of 'A' fails to print.
Thanks
Varun