Reputation: 131
I have an object $burStageStats
that I fill with data.
my $additional_event_details = {
'status' => '\N',
'duration' => '\N',
'keyword' => $keyword
};
my $statsHash = {
'time' => '\N',
'event_type' => 'INFO',
'backup_stage' => '\N',
'additional_event_details' => $additional_event_details
};
push (@burStageStats, $statsHash);
Later I loop through and print the values to a BCP file
foreach my $backup (@{$burStageStats}) {
foreach my $backupStage ($backup) {
print BCP "$siteId\t" . $backupStage->{'time'} . "\t" .
$backupStage->{'event_type'} . "\t" .
$stageIdMap->{$backupStage->{'additional_event_details'}->{'backup_stage'}} . "\n";
}
}
I get the following error
Use of uninitialized value in concatenation (.) or string at /data/ddp/current/analysis/TOR/bur/parseburLog line 180, line 11287.
Which I imagine points to the way I reference in the line
$stageIdMap->{$backupStage->{'additional_event_details'}->{'backup_stage'}} . "\t" .
But I am not sure how to write that line properly. The code works but I would like less errors reported obviously.
Upvotes: 0
Views: 45
Reputation: 46187
The warning tells us that $backupStage->{'additional_event_details'}->{'backup_stage'}
returns a value which does not exist in the hash referenced by $stageIdMap
. e.g., If $backupStage->{'additional_event_details'}->{'backup_stage'}
is 'foo', then $stageIdMap->{'foo'}
is missing or undefined.
Given the example data at the top of your question, I note that $backupStage->{'additional_event_details'}->{'backup_stage'}
does not exist in that example data - the $additional_event_details
hash doesn't include a backup_stage
key. backup_stage
is in $statsHash
, not $backupStage->{'additional_event_details'}
. This seems likely to be the root problem, as there's a very good chance that $stageIdMap->{undef}
(for an actual undef
, not the string 'undef') doesn't exist.
If you were to provide a short, self-contained example program which we can run for ourselves to see the problem in action, then we would be able to provide more definite (and probably more useful) assistance.
Upvotes: 2