I'm storing a hash references from a threads to a shared @stories variable, and then can't access them.
my @stories : shared= ();
sub blah {
my %stories : shared=();
<some code>
if ($type=~/comment/) {
$stories{"$id"}="$text";
$stories{"$id"}{type}="$type";
lock @stories;
push @stories, \%stories;
}
}
# @stories is a list of hash references which are shared from the threads;
foreach my $story (@stories) { my %st=%{$story}; print keys %st; # <- printed "8462529653954" print Dumper %st; # <- OK my $st_id = keys %st; print $st_id; # <- printed "1" print $st{$st_id}; # <- printed "1/8" }
print keys %st works as expected but when i set in to a variable and print, it returns "1".
Could you please advice what I'm doing wrong. Thanks in advance.