Sun751 has asked for the wisdom of the Perl Monks concerning the following question:
the key of the hash is constant where as value always change so in some subroutine if I want to extract and use the value of some key, suppose "xyz". How can that be done? Can any one suggest me please!!! Cheerssub initilize_config { my ($HR_config,$file) = @_; open (my $fr, '<', "$file") || die "Unable to open configuration f +ile: $file $!"; while (my $line = <$fr>) { $line =~ tr/\r\n//d; next unless $line; if ($line =~ /=/) { my ($key,$val)=$line=~ /^(.*?)=(.*?)$/; $$HR_config{$key} = $val; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting values from hash
by moritz (Cardinal) on Jul 01, 2009 at 08:25 UTC | |
|
Re: Extracting values from hash
by jrsimmon (Hermit) on Jul 01, 2009 at 11:39 UTC |