I want to ask you how can I read the specific hash from array [{},{},{}] using string key?
- First is an initialization
- There are 2x writing hashes to array
- I need to read the particular hash using string key
How can I do that?
sub SpecComp {
my ($this, $comp_name, $component, $index) = @_;
if ($component) {
$this->{specComp}[$index] = $component;
}
my $ref = \$this; #?????
return $ref; #?????
}
sub new {
my $this = {};
my $this->{specComp} = [];
return $this;
}
# Initialize
my $ts = new test();
# I want to write - it is OK
my $Comp1 = {
"ANOZZLE" => "first",
};
$ts->SpecComp("ANOZZLE", $Comp1, 1);
my $Comp2 = {
"BBUCKET" => "second",
};
$ts->SpecComp("BBUCKET", $Comp2, 2);
# I want to read - is not OK
my $out = SpecComp("ANOZZLE");
print $out; # ???????? I want output $Comp1
testcoming from? Why are you usingnewwithout bless?