Hi,
I'm trying to use Hash references with Tie::Hash but I'm a little confused as to how this is working out so far. Can somebody please explain to me the output and the correct way to implement this? Thanks!
Regards, San
Output:
If I uncomment the "return $h;" there is the following output:
---
cheers!
san
print length "answer to life the universe and everything";
I'm trying to use Hash references with Tie::Hash but I'm a little confused as to how this is working out so far. Can somebody please explain to me the output and the correct way to implement this? Thanks!
Regards, San
Code:
package Tie_Test;
use Tie::Hash;
use Data::Dumper;
use vars qw(@ISA);
@ISA = qw(Tie::StdHash);
sub STORE
{
my ( $self, $key, $value ) = @_;
print "STORE: [$key, $value ]", Dumper($key, $value), "\n";
}
sub FETCH
{
my ( $self, $key ) = @_;
print "FETCH: ", Dumper($key), "\n";
#return $h;
}
tie my %config, 'Tie_Test';
$config{'dsn'}->{'test'} = 44;
1;
Output:
Code:
FETCH: $VAR1 = 'dsn'; #Fetch called first?
If I uncomment the "return $h;" there is the following output:
Code:
FETCH: $VAR1 = 'dsn';
STORE: [dsn, HASH(0x18d34d0) ]$VAR1 = 'dsn';
$VAR2 = {};
---
cheers!
san

print length "answer to life the universe and everything";