Device-OUI
view release on metacpan or search on metacpan
lib/Device/OUI.pm view on Meta::CPAN
sub update_from_file {
my $self = shift;
my $oui = $self->norm;
my $cf = $self->cache_file;
if ( ! $cf ) { return }
my $fh = IO::File->new( $cf, 'r' );
if ( ! $fh ) { return }
local $/ = "";
while ( my $entry = $fh->getline ) {
if ( substr( $entry, 0, 8 ) eq $oui ) {
my $data = $self->parse_oui_entry( $entry );
$self->cache( $data );
return $data;
}
}
return;
}
lib/Device/OUI.pm view on Meta::CPAN
return;
}
sub load_cache_from_file {
my $self = shift;
my $file = shift;
if ( ! $file ) { $file = $self->cache_file }
if ( ! $file ) { return }
my $fh = IO::File->new( $file );
local $/ = "";
$fh->getline; # dump the header
my $counter = 0;
while ( my $entry = $fh->getline ) {
my $data = $self->parse_oui_entry( $entry );
$self->cache( $data->{ 'oui' } => $data );
$counter++;
}
return $counter;
}
t/functions.t view on Meta::CPAN
my $ref = shift( @ordered );
while ( @ordered ) {
my $test = shift( @ordered );
is( oui_cmp( $ref, $test ), -1, "oui_cmp( $ref < $test )" );
is( oui_cmp( $test, $ref ), +1, "oui_cmp( $ref > $test )" );
}
{
my $fh = IO::File->new( "$Bin/minimal-oui.txt" ) or die "$!";
local $/ = "";
$fh->getline;
my @samples = samples();
while ( my $entry = $fh->getline ) {
my $data = parse_oui_entry( $entry );
my $ref = shift( @samples );
delete $ref->{ $_ } for qw( _private );
is_deeply( $data, $ref, "parse_oui_entry" );
}
}
( run in 0.424 second using v1.01-cache-2.11-cpan-49f99fa48dc )