L
Lynn
Hi All
I am having problems accessing a data structure created from an Ingres
database. I have
a hash of hashes where the value is an array. What I am trying to do is
increment the
value of the first entry in the array. I have provided a little test script
that shows my
problem.
#!/usr/bin/perl
use strict;
use warnings;
use Data:
umper;
use diagnostics;
my $people = {
'robert' => {
'TUSHYATI MAUDGALYA' => [
0,
0,
0
],
'JESSICA LEE' => [
0,
0,
0
],
'JOHN HUSTON' => [
0,
0,
0
]
},
'christie' => {
'LARRY KRUGER' => [
0,
0,
0
],
'JEFFREY SIMONSON' => [
0,
0,
0
]
}
};
my $manager = {
'LARRY KRUGER' =>'christie',
'JEFFREY SIMONSON' =>'christie',
'TUSHYATI MAUDGALYA' => 'robert',
'JESSICA LEE' => 'robert',
'JOHN HUSTON' => 'robert'
};
my @tmp = ('LARRY KRUGER', 'JEFFREY SIMONSON', 'TUSHYATI MAUDGALYA',
'JESSICA LEE', 'JOHN HUSTON');
foreach my $person(@tmp) {
${$people->${$manager->{$person} } }{$person}[0]++;
}
print Dumper($people);
Can't use string ("christie") as a SCALAR ref while "strict refs" in use at
G:\hillr\test1.pl line 55 (#1)
(F) Only hard references are allowed by "strict refs". Symbolic
references are disallowed. See perlref.
Uncaught exception from user code:
Can't use string ("christie") as a SCALAR ref while "strict refs" in
use
I looked at the perlref as suggested in the error message and found this:
Anywhere you'd put an identifier (or chain of identifiers) as part
of a variable or subroutine name, you can replace the identifier
with a BLOCK returning a reference of the correct type. In other
words, the previous examples could be written like this:
$bar = ${$scalarref};
push(@{$arrayref}, $filename);
${$arrayref}[0] = "January";
${$hashref}{"KEY"} = "VALUE";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
&{$coderef}(1,2,3);
$globref->print("output\n"); # iff IO::Handle is loaded
I'm trying that one to access the hash but still come up with the error.
What am I doing wrong?
Thanks !!!
I am having problems accessing a data structure created from an Ingres
database. I have
a hash of hashes where the value is an array. What I am trying to do is
increment the
value of the first entry in the array. I have provided a little test script
that shows my
problem.
#!/usr/bin/perl
use strict;
use warnings;
use Data:
use diagnostics;
my $people = {
'robert' => {
'TUSHYATI MAUDGALYA' => [
0,
0,
0
],
'JESSICA LEE' => [
0,
0,
0
],
'JOHN HUSTON' => [
0,
0,
0
]
},
'christie' => {
'LARRY KRUGER' => [
0,
0,
0
],
'JEFFREY SIMONSON' => [
0,
0,
0
]
}
};
my $manager = {
'LARRY KRUGER' =>'christie',
'JEFFREY SIMONSON' =>'christie',
'TUSHYATI MAUDGALYA' => 'robert',
'JESSICA LEE' => 'robert',
'JOHN HUSTON' => 'robert'
};
my @tmp = ('LARRY KRUGER', 'JEFFREY SIMONSON', 'TUSHYATI MAUDGALYA',
'JESSICA LEE', 'JOHN HUSTON');
foreach my $person(@tmp) {
${$people->${$manager->{$person} } }{$person}[0]++;
}
print Dumper($people);
Can't use string ("christie") as a SCALAR ref while "strict refs" in use at
G:\hillr\test1.pl line 55 (#1)
(F) Only hard references are allowed by "strict refs". Symbolic
references are disallowed. See perlref.
Uncaught exception from user code:
Can't use string ("christie") as a SCALAR ref while "strict refs" in
use
I looked at the perlref as suggested in the error message and found this:
Anywhere you'd put an identifier (or chain of identifiers) as part
of a variable or subroutine name, you can replace the identifier
with a BLOCK returning a reference of the correct type. In other
words, the previous examples could be written like this:
$bar = ${$scalarref};
push(@{$arrayref}, $filename);
${$arrayref}[0] = "January";
${$hashref}{"KEY"} = "VALUE";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
&{$coderef}(1,2,3);
$globref->print("output\n"); # iff IO::Handle is loaded
I'm trying that one to access the hash but still come up with the error.
What am I doing wrong?
Thanks !!!