I'm trying to create a proper blessed reference to a constant hash and the below code works but I'm not sure if its the proper 'Perl' way to do it.
package....
....
use Hash::Util qw<lock_hash>;
sub new {
my ($self, $data, $left, $right) = @_;
my %h = (DATA => $data, LEFT => $left, RIGHT => $right);
my $r = bless \%h, $self;
lock_hash($r->%*);
$r;
}
1;
Any pointers or tips?
The Ullich update
package....
....
use Hash::Util qw<lock_hash>;
sub new {
my ($self, $data, $left, $right) = @_;
my %h = (DATA => $data, LEFT => $left, RIGHT => $right);
lock_hashref(bless \%h, $self);#The Ullrich update
}
1;