romandas has asked for the wisdom of the Perl Monks concerning the following question:
Note that I do not own this code. I believe I pulled it from CPAN, and that it rightfully belongs to James MacFarlane. If this is incorrect, let me know and I'll attribute it accordingly. I couldn't find where I originally pulled it from.
Here are the relevant snippets:
#----------------------------------------------------------------- package Node; #----------------------------------------------------------------- sub new { my ($pkg, $ip, $mac, $hostname) = @_; my $obj = {}; bless $obj, $pkg; $obj->IP_Address($ip); $obj->MAC_Address($mac); $obj->Hostname($hostname); return $obj; }
So, from what I see above, Node->new() should be called using 4 arguments. However, when the original author used Node->new(), he did this:
$nodeobj = Node->new($ip, $mac_address, $machine); push(@nodes, $nodeobj);
This only uses three arguments. And if you omit one, then it appears the values would suffer a sort of 'one off' error. But.. the code appears to work fine. What gives?
Update: Thanks all!
Back to
Seekers of Perl Wisdom