Git Product home page Git Product logo

netaddr-ip-find's Introduction

NAME
    NetAddr::IP::Find - Find IP addresses in plain text

SYNOPSIS
      use NetAddr::IP::Find;
      $num_found = find_ipaddrs($text, \&callback);

DESCRIPTION
    This is a module for finding IP addresses in plain text.

  Functions

    NetAddr::IP::Find exports one function, find_ipaddrs(). It works very
    similar to URI::Find's find_uris() or Email::Find's find_emails().

      $num_ipaddrs_found = find_ipaddrs($text, \&callback);

    The first argument is a text to search through and manipulate. Second is
    a callback routine which defines what to do with each IP address as
    they're found. It returns the total number of IP addresses found.

    The callback is given two arguments. The first is a NetAddr::IP instance
    representing the IP address found. The second is the actual IP address
    as found in the text. Whatever the callback returns will replace the
    original text.

EXAMPLES
      # For each IP address found, ping its host to see if its alive.
      use Net::Ping;
      my $pinger = Net::Ping->new;
      my %pinged;
      find_ipaddrs($text, sub {
                       my($ipaddr, $orig) = @_;
                       my $host = $ipaddr->to_string;
                       next if exists $pinged{$host};
                       $pinged{$host} = $pinger->ping($host);
                   });

      while (my($host, $up) == each %pinged) {
          print "$host is " . $up ? 'up' : 'down' . "\n";
      }

      # Resolve IP address to FQDN
      find_ipaddrs($text, sub {
                       my($ipaddr, $orig) = @_;
                       resolve_ip($ipaddr->to_string);
                   });

      sub resolve_ip {
          use Net::DNS;
          # see perldoc Net::DNS for details
      }

TODO
    *   Subnet support.

    *   IPv6 support.

AUTHOR
    Tatsuhiko Miyagawa <[email protected]>

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

SEE ALSO
    the NetAddr::IP manpage, the URI::Find manpage, the Email::Find manpage,
    jdresove

netaddr-ip-find's People

Contributors

miyagawa avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.