Exemple d'utilisation (1)

Simple écoute passive du réseau


#!/usr/bin/perl -W
use strict;
use NetworkInfo::Discovery;
use NetworkInfo::Discovery::Register;
use NetworkInfo::Discovery::Sniff;

my $data = new NetworkInfo::Discovery::Register (
        'file' => 'sample.register', 'autosave' => 1
    ) or warn "Cannot create new object";

my $sniff = new NetworkInfo::Discovery::Sniff maxcapture => 10;
$sniff->do_it;

$data->add_interface($_) for ($sniff->get_interfaces)
$data->write_register;

for (@{$data->{interfaces}}) {
    print "interface: ",$_->{ip},'/',$_->{mask},$/
}


Journées Perl 2004 10 / 32