quick question about pushing to a multi-dimensional hash in Perl. I have the following variables:
%pids #name of hash
$pid = 24633 #key of the has
$time 00:0 #time reference
$line #has a line full of data
I am inputing $pid and $time in from $line. If the key 24633 exists along with reference element 05:3, then it add the line to 05:3 and use 05:3 as a key.
pids{24633}{05:3}
I've tried:
if ($pids{$pid}{$time}){
@{$pids{$pid}{$time}} -> $line;
}
I've also tried this:
if ($pids{$pid}{$time}){
push @{$pids{$pid}{$time}}, $line;
But it's keep giving me a "Not a HASH reference" when it tries to do the push. Any suggestions? Thanks!
This is how I'm building the hash:
foreach my $key (keys %pids){
if ($key =~ $mPID){
push @messages, $line;
}
}
Here's the hash structure:
$VAR1 = {
'17934' => [
'14:3'
],
'17955' => [
'13:3'
],
'24633' => [
'05:3'
],
'6771' => [
'04:1'
],
'7601' => [
'06:0'
],
};
$key, but store$line.)