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!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.