I have inherited a program that does snmp walks and gets,
but within the code (keep in mind they turned off strict for references) I am failing to understand the push @$node_type “$name”; The person who wrote this said with strict on the push
statement above will not work…complains about a scalar is undefined.
I said yes it will not b/c you can only push an array and $ is scalar, arrays
in scalar context return the count of elements. His reply was well I am doing this b/c I need to create a
dynamic array composed of all device types. Is this bad code as I have never seen push @$arrayname? Please explain what this is doing. Thank you use strict; no strict "refs"; use warnings; my @network_node_types =
("CiscoAPVPN","CiscoASYNC","CiscoSwitches"); my @storage_node_types =
("BrocadeSwitches"); my @all_node_types =
(@network_node_types,@storage_node_types); sub get_node_lists_by_type { ## These "node
types" are filters defined within Network Node Manager (NNM). ## This makes it easy
to map node names to their type for querying. ## The "format
script" is nothing but an "ovtopodump" from NNM and the ## subsequent
formatting to produce lines with a name and an OID string. ## We split each
string and store the name and OID for later use. my
($node_type,$name,$oid); foreach $node_type
(@all_node_types) { open(TEMP,
"$formatscript $node_type |") || die ("open $formatscript
failed: $!"); while ( <TEMP>
) { ($name,$oid) =
split; $oid =~
s/^\.//; push
@$node_type, "$name"; $oid{$name} =
"$oid"; } close TEMP; } } Derek Bellner Smith Unix Systems Engineer Cardinal Health
Dublin, 614-757-5000 614-757-8120 Fax _________________________________________________ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese - Svenska: www.cardinalhealth.com/legal/email |
ITAM_asset_gather.bak
Description: ITAM_asset_gather.bak
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>