-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Anthony Ettinger
Sent: Friday, July 07, 2006 1:27 PM
To: Smith, Derek
Subject: Re: inherited perl program

On 7/7/06, Smith, Derek <[EMAIL PROTECTED]> wrote:
>
>
>
>
> 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";
>
>
> 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;
>
>  }
>
>
>
> }
>
>
>
>


> It's an array reference, he's de-referencing it with @$arrayRef.


I know there are a lot of questions but this helps me understand.  Thank
you!

The code is not ideal as use strict complains so what is the correct
way?

What array is he dereferencing?  $node_type is not the array
@all_node_types is. I am confused with this de-referencing.  So the data
for each Cisco device or Brocade device from the formatscript is being
stored in what [EMAIL PROTECTED]

What benefit does this de-reference give us?
So as he is looping through @all_node_types he is "de-referencing" each
element which is a referent to @storage_node_types and
@network_node_types?
 
I would of recognized if the code included a -> for de-reference and if
he would of set the reference using \@, but after looking in programming
perl the $@ is one way to de-reference.

So @$ de-references the entire array, but does -> ?
What would the code above look like if I were to use -> ?

_________________________________________________

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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to