5290589 发表于 2018-8-31 09:03:16

perl 判断ip是否在某个子网

  #!/usr/bin/perl -w
  use Net::IP;
  my $ip= new Net::IP('192.168.0.0');
  my $cut=16;
  my $net1=substr($ip->binip(),0,$cut);
  my $input=$ARGV;
  my $new=new Net::IP($input);
  my $net2=substr($new->binip(),0,$cut);
  print "$net1\n$net2\n";
  if($net1 eq $net2)
  {
  print "yes\n";
  }
  else{
  print "no\n";
  }

页: [1]
查看完整版本: perl 判断ip是否在某个子网