[Kc] Since everyone is on a roll today .. is this the most efficient ...
djgoku
djgoku at gmail.com
Wed Sep 19 15:29:17 PDT 2007
On 9/19/07, Daryl Fallin <darylvf at gmail.com> wrote:
> I haven't posted for awhile and still consider myself a total PERL newbie,
> so I use the following perl to convert decimal IP notation to Quad IP
> notation. Is there a better way?
>
> Also as you can see my use of $_[0] which works, but seems odd. Now I can't
> remember why I did it that way.
>
> ###########################
> # subroutine: getip( $int )
> ###########################
> sub getip
> {
> my $ipinteger = $_[0];
> #print "TEST: $_[0]\n";
> my $ipbin = ip_inttobin($ipinteger, 4);
> my $ipquad = ip_bintoip($ipbin, 4);
> my $TypeIP = new Net::IP ($ipquad) or die (Net::IP::Error());
> #print "**IP IS: $ipquad\n";
> return $ipquad;
> }
You could do:
my $ipinteger = shift;
or maybe:
# this is one is weird since you don't have a list of arguments
my ($ipinteger) = @_;
As FrankW said, I also am not sure why you are even creating the object.
More information about the kc
mailing list