K
karthikd
Hello All,
I have some basic knowledge of Perl and I am troubleshooting a Perl
code(it is perl-SNMP-NPAdmin perl module)to debug a particular
problem.
I am not able to understand some part of the code (which is using some
hashes etc.).
The following snippet of code is used in NPAdmin.pm file:
sub model
{
#warn "model";
my $self= shift;
for ( $self->vendor()->{vendor} )
{
.....snipped code....
/^HP$/ && do {
my $str= $self->{Neon}->hp_gdStatusId()->{gdStatusId};
print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: $str \n";
$self->{model}= ( $str =~ /;(?:MODEL|MDL):\s*(.+?)\s*;/ )[0];
last;
};
.....snipped code ...
}
return { model => $self->{model} };
}
I added the print statement to know what value is stored in $str.
While running the module, we found that $str value is empty.
My query is what the line below:
my $str= $self->{Neon}->hp_gdStatusId()->{gdStatusId};
does really and how to troubleshoot/debug it in a failure case.
hp_gdStatusId seems to be a key in a hash called %list_map defined in
another perl module called in Neon.pm
%list_map= (
# sub name oid list
# -------- --------
hp_npCfgSource => [ 0x0,
[ q:
[ '.iso.org.dod.internet.private.enterprises.hp.nm.interface.npCard.npCfg.npCfgSource',
0],
: ],
],
hp_gdStatusId => [ 0x0,
[ q:
[ '.iso.org.dod.internet.private.enterprises.hp.nm.system.net-
peripheral.net-printer.generalDeviceStatus.gdStatusId', 0]
: ],
],
);
and list_map is used like this in a subroutine called AUTOLOAD defined
in Neon.pm
sub AUTOLOAD
{
<code snipped >
elsif ( defined $list_map{$autoload} )
{
my @map= @{$list_map{$autoload}};
$sub= $list_code;
%tags= (
'##SUBNAME##' => $autoload,
'##MIBS##' => $map[0],
'##OIDLIST##' => @{$map[1]},
);
}
<code snipped>
}
Any help would be really appreciated.
Thanks & Regards,
Karthik
I have some basic knowledge of Perl and I am troubleshooting a Perl
code(it is perl-SNMP-NPAdmin perl module)to debug a particular
problem.
I am not able to understand some part of the code (which is using some
hashes etc.).
The following snippet of code is used in NPAdmin.pm file:
sub model
{
#warn "model";
my $self= shift;
for ( $self->vendor()->{vendor} )
{
.....snipped code....
/^HP$/ && do {
my $str= $self->{Neon}->hp_gdStatusId()->{gdStatusId};
print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: $str \n";
$self->{model}= ( $str =~ /;(?:MODEL|MDL):\s*(.+?)\s*;/ )[0];
last;
};
.....snipped code ...
}
return { model => $self->{model} };
}
I added the print statement to know what value is stored in $str.
While running the module, we found that $str value is empty.
My query is what the line below:
my $str= $self->{Neon}->hp_gdStatusId()->{gdStatusId};
does really and how to troubleshoot/debug it in a failure case.
hp_gdStatusId seems to be a key in a hash called %list_map defined in
another perl module called in Neon.pm
%list_map= (
# sub name oid list
# -------- --------
hp_npCfgSource => [ 0x0,
[ q:
[ '.iso.org.dod.internet.private.enterprises.hp.nm.interface.npCard.npCfg.npCfgSource',
0],
: ],
],
hp_gdStatusId => [ 0x0,
[ q:
[ '.iso.org.dod.internet.private.enterprises.hp.nm.system.net-
peripheral.net-printer.generalDeviceStatus.gdStatusId', 0]
: ],
],
);
and list_map is used like this in a subroutine called AUTOLOAD defined
in Neon.pm
sub AUTOLOAD
{
<code snipped >
elsif ( defined $list_map{$autoload} )
{
my @map= @{$list_map{$autoload}};
$sub= $list_code;
%tags= (
'##SUBNAME##' => $autoload,
'##MIBS##' => $map[0],
'##OIDLIST##' => @{$map[1]},
);
}
<code snipped>
}
Any help would be really appreciated.
Thanks & Regards,
Karthik