This code works ok but I don't like it much, inelegant.
use strict;
my %cfg = (
[tab]'oracle_sid' => ''
)
print "oracle_sid=$cfg{'oracle_sid'}\n";
init(\%cfg);
print "oracle_sid=$cfg{'oracle_sid'}\n";
sub init{
[tab]$_[0]{'oracle_sid'} = 'Mike';
}
[/code]
The value of $cfg{'oracle_sid'} is left at 'Mike' after the subroutine call.
But it's not pretty is it... (and, more to the point, not very readable if I have a whole list of parameters)
I'd like to be able to refer to the hash by name, something like this (this doesn't work btw)
Perldoc perlref sort of implies that you can do this, but stops short of explaining to a mere mortal like myself just how I should do it.
I'd be grateful if someone would point out my glaring misunderstanding B-( (I *hate* not knowing stuff....)
use strict;
my %cfg = (
[tab]'oracle_sid' => ''
)
print "oracle_sid=$cfg{'oracle_sid'}\n";
init(\%cfg);
print "oracle_sid=$cfg{'oracle_sid'}\n";
sub init{
[tab]$_[0]{'oracle_sid'} = 'Mike';
}
[/code]
The value of $cfg{'oracle_sid'} is left at 'Mike' after the subroutine call.
But it's not pretty is it... (and, more to the point, not very readable if I have a whole list of parameters)
I'd like to be able to refer to the hash by name, something like this (this doesn't work btw)
Code:
sub init{
my $href = \$_[0];
[tab]$href{'oracle_sid'} = 'Mike';
}
I'd be grateful if someone would point out my glaring misunderstanding B-( (I *hate* not knowing stuff....)