Changeset 55 for trunk/klask


Ignore:
Timestamp:
Jul 24, 2009, 1:35:52 AM (15 years ago)
Author:
g7moreau
Message:
  • Suppress some perlcritic warning level 2
    • remove the last unless test
    • add /m to regex
    • suppress double-sigil dereference
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r54 r55  
    165165
    166166#   my $cmdarping  = `arping -c 1 -w 1 -rR $param 2>/dev/null`;
    167    if ( not $param_ip_or_host =~ m/^\d+ \. \d+ \. \d+ \. \d+$/x ) {
    168       $param_ip_or_host =~ s/ \. .* //x;
     167   if ( not $param_ip_or_host =~ m/^\d+ \. \d+ \. \d+ \. \d+$/xms ) {
     168      $param_ip_or_host =~ s/ \. .* //xms;
    169169      }
    170170
     
    216216   #$ret{hostname_fq}  = $param_ip_or_host if not defined $1 and $ret{hostname_fq} eq 'unknow';
    217217
    218    unless ($ret{mac_address} eq 'unknow') {
     218   if ($ret{mac_address} ne 'unknow') {
    219219      my @paquets = ();
    220       foreach ( split m/ : /x, $ret{mac_address} ) {
     220      foreach ( split m/ : /xms, $ret{mac_address} ) {
    221221         my @chars = split m//xms, uc("00$_");
    222222         push @paquets, "$chars[-2]$chars[-1]";
     
    233233
    234234   for my $sw_kind (keys %SWITCH_KIND) {
    235       next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/x;
     235      next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/xms;
    236236
    237237      return $SWITCH_KIND{$sw_kind}->{model};
     
    445445      my @line  = @{$KLASK_CFG->{network}{$net}{'ip-subnet'}};
    446446      for my $cmd (@line) {
    447          for my $method (keys %$cmd){
     447         for my $method (keys %{$cmd}){
    448448            $cidrlist->add_any($cmd->{$method}) if $method eq 'add';
    449449            }
     
    455455   for my $cidr ($cidrlist->list()) {
    456456      my $net = new NetAddr::IP $cidr;
    457       for my $ip (@$net) {
    458          $ip =~ s{ /32 }{}x;
     457      for my $ip (@{$net}) {
     458         $ip =~ s{ /32 }{}xms;
    459459         push @res,  $ip;
    460460         }
     
    599599
    600600   my $number_of_computer = get_list_ip(@network); # + 1;
    601    my $size_of_database   = keys %$computerdb;
     601   my $size_of_database   = keys %{$computerdb};
    602602      $size_of_database   = 1 if $size_of_database == 0;
    603603   my $i = 0;
     
    747747
    748748   my $dirdb = $KLASK_DB_FILE;
    749       $dirdb =~ s{ / [^/]* $}{}x;
     749      $dirdb =~ s{ / [^/]* $}{}xms;
    750750   mkdir "$dirdb", 0755 unless -d "$dirdb";
    751751   YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb);
     
    775775
    776776   my $dirdb = $KLASK_DB_FILE;
    777       $dirdb =~ s{ / [^/]* $}{}x;
     777      $dirdb =~ s{ / [^/]* $}{}xms;
    778778   mkdir "$dirdb", 0755 unless -d "$dirdb";
    779779   YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb);
     
    810810
    811811   LOOP_ON_IP_ADDRESS:
    812    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %$computerdb)) {
     812   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    813813
    814814#      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq 'unknow';
     
    874874   my %mac_count = ();
    875875   LOOP_ON_IP_ADDRESS:
    876    foreach my $ip (keys %$computerdb) {
     876   foreach my $ip (keys %{$computerdb}) {
    877877
    878878      # to be improve in the future
     
    885885
    886886   LOOP_ON_IP_ADDRESS:
    887    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %$computerdb)) {
     887   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    888888
    889889      # to be improve in the future
     
    907907      my $mac_sort = sprintf "%04i-%s", 9999 - $mac_count{$computerdb->{$ip}{mac_address}}, $computerdb->{$ip}{mac_address};
    908908
    909       $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/x;
     909      $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/xms;
    910910      my ( $host_short ) = split m/ \. /xms, $computerdb->{$ip}{hostname_fq};
    911911
     
    10441044
    10451045   LOOP_ON_IP_ADDRESS:
    1046    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %$computerdb)) {
     1046   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    10471047
    10481048      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
Note: See TracChangeset for help on using the changeset viewer.