| P2P-pDonkey documentation | Contained in the P2P-pDonkey distribution. |
P2P::pDonkey::Util - Utility functions for P2P::pDonkey extensions.
use P2P::pDonkey::Util ':all';
print ip2addr(addr2ip('176.16.5.33')), "\n";
Analog for inet_aton, but returns unpacked ip number.
Analog inet_ntoa, take as argument unpacked ip number.
None by default.
Alexey Klimkin, <klimkin@mail.ru>
perl, Socket.
| P2P-pDonkey documentation | Contained in the P2P-pDonkey distribution. |
# P2P::pDonkey::Util.pm # # Copyright (c) 2003-2004 Alexey klimkin <klimkin at cpan.org>. # All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # package P2P::pDonkey::Util; use 5.006; use strict; use warnings; require Exporter; our $VERSION = '0.05'; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( addr2ip ip2addr ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); # Preloaded methods go here. use Socket qw (inet_aton inet_ntoa); sub addr2ip { my $ip; $ip = inet_aton($_[0]); defined $ip || return 0; return unpack('L', $ip); } sub ip2addr { return inet_ntoa(pack('L', $_[0])); } 1; __END__