I always forget how to do this.
I have this Perl code:
print Dumper($obj);
Here is my Data::Dumper output:
$VAR1 = {
'classname' => 'Template',
'oid' => 2,
'pid' => '50'
};
But when I do something like ...
print LOGGER "classname is [\n". $obj{'classname'} . "]\n";
... I get this error ...
Use of uninitialized value in concatenation (.) or string at
what am I doing wrong here?
You should have used $obj->{'classname'}
. Without the arrow, $obj{'classname'}
accesses the %obj
hash instead of the hashref in $obj
.
This is the sort of error that gets caught by use strict;
so your real error is not doing that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.