Changeset 50 for trunk/klask


Ignore:
Timestamp:
Jul 23, 2009, 11:24:08 PM (15 years ago)
Author:
g7moreau
Message:
  • Suppress warning perlcritic level 3 Regular expression without "/x" flag
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r49 r50  
    148148
    149149#   my $cmdarping  = `arping -c 1 -w 1 -rR $param 2>/dev/null`;
    150    if (not $param_ip_or_host =~ m/^\d+\.\d+\.\d+\.\d+$/) {
    151       $param_ip_or_host =~ s/\..*//;
     150   if ( not $param_ip_or_host =~ m/^\d+ \. \d+ \. \d+ \. \d+$/x ) {
     151      $param_ip_or_host =~ s/ \. .* //x;
    152152      }
    153153
     
    161161   my $cmd_arpwatch = `$cmd`;
    162162   chomp $cmd_arpwatch;
    163    my ($arp, $ip, $timestamp, $host) = split /\s+/, $cmd_arpwatch;
     163   my ($arp, $ip, $timestamp, $host) = split m/ \s+ /x, $cmd_arpwatch;
    164164
    165165   $ret{ipv4_address} = $ip        if $ip;
     
    179179   my $cmd_arp  = `arp -a $param_ip_or_host 2>/dev/null`;
    180180   chomp $cmd_arp;
    181    $cmd_arp =~ /(\S*)\s\(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\)\sat\s([0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2})/;
     181   $cmd_arp =~ /(\S*)\s\(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\)\sat\s([0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2})/x;
    182182   $ret{hostname_fq}  = $1 if(defined($1));
    183183   $ret{ipv4_address} = $2 if(defined($2));
     
    188188   my $cmd_host = `host $param_ip_or_host 2>/dev/null`;
    189189   chomp $cmd_host;
    190    $cmd_host =~ m/domain\sname\spointer\s(\S+)\.$/;
     190   $cmd_host =~ m/domain \s name \s pointer \s (\S+) \.$/x;
    191191   $ret{hostname_fq} = $1 if defined $1;
    192192
    193193   # resultat de la commande host si parametre est hostname
    194194   # tech7meylan.hmg.inpg.fr has address 194.254.66.240
    195    $cmd_host =~ m/(\S*)\shas\saddress\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/;
     195   $cmd_host =~ m/(\S*) \s has \s address \s ( [0-9]{1,3} \. [0-9]{1,3} \. [0-9]{1,3} \. [0-9]{1,3} )$/x;
    196196   $ret{hostname_fq}  = $1 if defined $1;
    197197   $ret{ipv4_address} = $2 if defined $2;
    198198
    199    $cmd_host =~ m/\b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.in-addr\.arpa\s/;
     199   $cmd_host =~ m/ \b ([0-9]{1,3}) \. ([0-9]{1,3}) \. ([0-9]{1,3}) \. ([0-9]{1,3}) \. in-addr \. arpa \s/x;
    200200   $ret{ipv4_address} = "$4.$3.$2.$1"     if defined $1 and  defined $2 and  defined $3 and  defined $4;
    201201   $ret{hostname_fq}  = $param_ip_or_host if not defined $1 and $ret{hostname_fq} eq 'unknow';
     
    203203   unless ($ret{mac_address} eq 'unknow') {
    204204      my @paquets = ();
    205       foreach ( split(/:/, $ret{mac_address}) ) {
    206          my @chars = split //, uc("00$_");
     205      foreach ( split m/ : /x, $ret{mac_address} ) {
     206         my @chars = split m//x, uc("00$_");
    207207         push @paquets, "$chars[-2]$chars[-1]";
    208208         }
     
    218218
    219219   for my $sw_kind (keys %SWITCH_KIND) {
    220       next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/;
     220      next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/x;
    221221
    222222      return $SWITCH_KIND{$sw_kind}->{model};
     
    287287      "A"=>"10", "B"=>"11", "C"=>"12", "D"=>"13", "E"=>"14", "F"=>"15"
    288288      );
    289    my @chars = split //, $car;
     289   my @chars = split m//x, $car;
    290290   return $table{$chars[-2]}*16 + $table{$chars[-1]};
    291291   }
     
    297297   my $arp = shift;
    298298
    299    my @paquets = split /:/, $arp;
     299   my @paquets = split m/ : /x, $arp;
    300300   my $return = '';
    301301   foreach(@paquets) {
     
    441441      my $net = new NetAddr::IP $cidr;
    442442      for my $ip (@$net) {
    443          $ip =~ s#/32##;
     443         $ip =~ s{ /32 }{}x;
    444444         push @res,  $ip;
    445445         }
     
    732732
    733733   my $dirdb = $KLASK_DB_FILE;
    734       $dirdb =~ s#/[^/]*$##;
     734      $dirdb =~ s{ / [^/]* $}{}x;
    735735   mkdir "$dirdb", 0755 unless -d "$dirdb";
    736736   YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb);
     
    760760
    761761   my $dirdb = $KLASK_DB_FILE;
    762       $dirdb =~ s#/[^/]*$##;
     762      $dirdb =~ s{ / [^/]* $}{}x;
    763763   mkdir "$dirdb", 0755 unless -d "$dirdb";
    764764   YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb);
     
    888888      my $switch_hostname_sort = sprintf "%s %3s" ,$switch_hostname, $computerdb->{$ip}{switch_port};
    889889
    890       my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ip);
     890      my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ip);
    891891
    892892      my $mac_sort = sprintf "%04i-%s", 9999 - $mac_count{$computerdb->{$ip}{mac_address}}, $computerdb->{$ip}{mac_address};
    893893
    894       $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^\d+\.\d+\.\d+\.\d+$/;
    895       my ( $host_short ) = split /\./, $computerdb->{$ip}{hostname_fq};
     894      $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/x;
     895      my ( $host_short ) = split m/ \. /x, $computerdb->{$ip}{hostname_fq};
    896896
    897897      print <<"END_HTML";
     
    932932      my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;
    933933
    934       my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ipv4_address);
     934      my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ipv4_address);
    935935
    936936      my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;
    937937
    938       my ( $host_short ) = sprintf "%s %3s" , split(/\./, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};
     938      my ( $host_short ) = sprintf "%s %3s" , split(m/ \. /x, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};
    939939
    940940      print <<"END_HTML";
     
    980980      my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min;
    981981
    982       my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ipv4_address);
     982      my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ipv4_address);
    983983
    984984      my $mac_sort = sprintf "%04i-%s", 9999, $mac_address;
     
    988988         if (exists $db_switch_output_port{$sw}) {
    989989
    990             my ( $host_short ) = sprintf "%s %3s" , split(/\./, $sw, 1), $db_switch_output_port{$sw};
     990            my ( $host_short ) = sprintf "%s %3s" , split( m/\./x , $sw, 1), $db_switch_output_port{$sw};
    991991
    992992            print <<"END_HTML";
     
    13671367   my %db_building= ();
    13681368   for my $sw (@SWITCH) {
    1369       my ($building, $location) = split /\//, $sw->{location}, 2;
     1369      my ($building, $location) = split m/ \/ /x, $sw->{location}, 2;
    13701370      $db_building{$building} ||= {};
    13711371      $db_building{$building}->{$location} ||= {};
Note: See TracChangeset for help on using the changeset viewer.