I am using DBIx::Wrapper to read in rows from a database. The DBIx::Wrapper functin 'nativeSelectMulti' returns the retrieved rows as an array of hashes. My problem is I cannot access the data in the array without errors. I use Data:
umper to dump the data and everything seems fine. But if I try to acces it in anyway it gives errors. My error output is below as well.
My code is as such:
# Retrieve list of districts within the state the lead is from.
while (my $lead = $leads->next) {
my @districts = $db->nativeSelectMulti( "SELECT * FROM rmg.District WHERE state=:state", { state => $$lead{state} } )
or die "Couldn't select districts: $!\n";
print Dumper( The only thing that works here is @districts);
}
If I type 'print Dumper( @districts);' I get the following output.
$VAR1 = [
{
'region' => '1',
'name' => 'Jacksonville',
'phone' => undef,
'state' => 'FL',
'city' => 'Jacksonville',
'employee' => '0',
'fax' => undef,
'id' => '58',
'address' => undef
},
{
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
}
];
Nothing wrong there.
Now if I type print Dumper( $districts[0] ); I get the same exact output
$VAR1 = [
{
'region' => '1',
'name' => 'Jacksonville',
'phone' => undef,
'state' => 'FL',
'city' => 'Jacksonville',
'employee' => '0',
'fax' => undef,
'id' => '58',
'address' => undef
},
{
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
}
];
If I type print Dumper( $districts[0]->{region} ); It print the first hash, when it should print just the value for region. Right?
Pseudo-hashes are deprecated at ./dispatch line 58. Line 58 being 'Print Dumper($districts blah blah
$VAR1 = {
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
};
Furthermore if I type print Dumper( $districts[0]->{region}->{region} ) or Dumper( $districts[0]->{region}->{name} or {region}->{phone} etc etc I get the following;
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = '1';
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = 'Miami';
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = undef;
$VAR1 is holding the correct value as you can see. That's what I'm looking for but I still get the Pseudo-hash error. And somethign is telling me $obj[0]->{value}->{value} is not the correct way to access the wanted variable. Any insight on this would be greatly appreciated.

My code is as such:
# Retrieve list of districts within the state the lead is from.
while (my $lead = $leads->next) {
my @districts = $db->nativeSelectMulti( "SELECT * FROM rmg.District WHERE state=:state", { state => $$lead{state} } )
or die "Couldn't select districts: $!\n";
print Dumper( The only thing that works here is @districts);
}
If I type 'print Dumper( @districts);' I get the following output.
$VAR1 = [
{
'region' => '1',
'name' => 'Jacksonville',
'phone' => undef,
'state' => 'FL',
'city' => 'Jacksonville',
'employee' => '0',
'fax' => undef,
'id' => '58',
'address' => undef
},
{
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
}
];
Nothing wrong there.
Now if I type print Dumper( $districts[0] ); I get the same exact output
$VAR1 = [
{
'region' => '1',
'name' => 'Jacksonville',
'phone' => undef,
'state' => 'FL',
'city' => 'Jacksonville',
'employee' => '0',
'fax' => undef,
'id' => '58',
'address' => undef
},
{
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
}
];
If I type print Dumper( $districts[0]->{region} ); It print the first hash, when it should print just the value for region. Right?
Pseudo-hashes are deprecated at ./dispatch line 58. Line 58 being 'Print Dumper($districts blah blah
$VAR1 = {
'region' => '1',
'name' => 'Miami',
'phone' => undef,
'state' => 'FL',
'city' => 'Miami',
'employee' => '0',
'fax' => undef,
'id' => '59',
'address' => undef
};
Furthermore if I type print Dumper( $districts[0]->{region}->{region} ) or Dumper( $districts[0]->{region}->{name} or {region}->{phone} etc etc I get the following;
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = '1';
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = 'Miami';
Pseudo-hashes are deprecated at ./dispatch line 58.
$VAR1 = undef;
$VAR1 is holding the correct value as you can see. That's what I'm looking for but I still get the Pseudo-hash error. And somethign is telling me $obj[0]->{value}->{value} is not the correct way to access the wanted variable. Any insight on this would be greatly appreciated.