1

perl脚本计算IP


由于工作上的需要,要将IP段计算成IP,perl的Net::IP刚好用上.

  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Net::IP;
  4. my $ip = new Net::IP ('192.168.0.0/24') or die;
  5. do {
  6.    print $ip -> ip(),"\n";
  7. } while(++$ip);

将文本文件的ip段计算成ip地址

  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Net::IP;
  4. open (A, "<wait.txt");
  5. while (<A>) {
  6.    my($a) = $_;
  7.    my $ip = new Net::IP ("$_") or die $!;
  8.    do {
  9.       print $ip -> ip(), "\n";
  10.    }
  11.    while (++$ip);
  12.          }

我猜~这些文章你可能也感兴趣

1 个留言:

  1. 石老人 on 二 8th, 2010 - 06:57

    兄弟,春节快乐啊!

    @恭喜恭喜!

给我留言:

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image