Changeset 54 for trunk


Ignore:
Timestamp:
Jul 24, 2009, 1:18:01 AM (15 years ago)
Author:
g7moreau
Message:
  • Work on Quotes for perlcritic warning level 2
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r53 r54  
    144144
    145145   my $fh = new Filehandle;
    146    open $fh, '-|', "$cmd" or die "Can't exec $cmd\n";
     146   open $fh, q{-|}, "$cmd" or die "Can't exec $cmd\n";
    147147   my $result = <$fh>;
    148148   close $fh;
     
    155155sub resolve_ip_arp_host {
    156156   my $param_ip_or_host = shift;
    157    my $interface = shift || '*';
    158    my $type      = shift || 'fast';
     157   my $interface = shift || q{*};
     158   my $type      = shift || q{fast};
    159159
    160160   my %ret = (
     
    222222         push @paquets, "$chars[-2]$chars[-1]";
    223223         }
    224       $ret{mac_address} = join ':', @paquets;
     224      $ret{mac_address} = join q{:}, @paquets;
    225225      }
    226226
     
    313313
    314314   my @paquets = split m/ : /xms, $arp;
    315    my $return = '';
     315   my $return = q{};
    316316   foreach(@paquets) {
    317       $return .= ".".hex_to_dec($_);
     317      $return .= q{.} . hex_to_dec($_);
    318318      }
    319319   return $return;
     
    324324sub find_switch_port {
    325325   my $arp             = shift;
    326    my $switch_proposal = shift || '';
     326   my $switch_proposal = shift || q{};
    327327
    328328   my %ret;
     
    333333
    334334   my @switch_search = @SWITCH;
    335    if ($switch_proposal ne '') {
     335   if ($switch_proposal ne q{}) {
    336336      for my $sw (@SWITCH) {
    337337         next if $sw->{hostname} ne $switch_proposal;
     
    341341      }
    342342
    343    my $research = "1.3.6.1.2.1.17.4.3.1.2".arp_hex_to_dec($arp);
     343   my $research = '1.3.6.1.2.1.17.4.3.1.2' . arp_hex_to_dec($arp);
    344344
    345345   LOOP_ON_SWITCH:
     
    675675            }
    676676
    677          my $switch_proposal = '';
     677         my $switch_proposal = q{};
    678678         if (exists $computerdb->{$resol_arp{ipv4_address}} and exists $computerdb->{$resol_arp{ipv4_address}}{switch_hostname}) {
    679679            $switch_proposal = $computerdb->{$resol_arp{ipv4_address}}{switch_hostname};
     
    10481048      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
    10491049
    1050       my $sw_hostname = $computerdb->{$ip}{switch_hostname} || '';
     1050      my $sw_hostname = $computerdb->{$ip}{switch_hostname} || q{};
    10511051      next if $sw_hostname eq 'unknow';
    10521052
    1053       my $sw_location = '';
     1053      my $sw_location = q{};
    10541054      for my $sw (@SWITCH) {
    10551055         next if $sw_hostname ne $sw->{hostname};
     
    10581058         }
    10591059
    1060       printf "%s: \"%s\"\n", $ip, $sw_location if not $sw_location eq '';
     1060      printf "%s: \"%s\"\n", $ip, $sw_location if not $sw_location eq q{};
    10611061      }
    10621062   return;
     
    10901090
    10911091sub cmd_search_mac_on_switch {
    1092    my $switch_name = shift || '';
    1093    my $mac_address = shift || '';
    1094 
    1095    if ($switch_name eq '' or $mac_address eq '') {
     1092   my $switch_name = shift || q{};
     1093   my $mac_address = shift || q{};
     1094
     1095   if ($switch_name eq q{} or $mac_address eq q{}) {
    10961096      die "Usage: klask search-mac-on-switch SWITCH_NAME MAC_ADDRESS\n";
    10971097      }
     
    11461146#   for my $one_computer ('194.254.66.254') {
    11471147   for my $one_router ( get_list_main_router(get_list_network()) ) {
    1148       my %resol_arp = resolve_ip_arp_host($one_router,'*','low');            # resolution arp
     1148      my %resol_arp = resolve_ip_arp_host($one_router, q{*}, q{low}); # resolution arp
    11491149      next DETECT_ALL_ROUTER if $resol_arp{mac_address} eq 'unknow';
    11501150      $where{$resol_arp{ipv4_address}} = find_all_switch_port($resol_arp{mac_address}); # retrouve les emplacements des routeurs
     
    11791179   ALL_SWITCH:
    11801180   for my $one_computer (@list_switch_ip) {
    1181       my %resol_arp = resolve_ip_arp_host($one_computer,'*','low'); # arp resolution
     1181      my %resol_arp = resolve_ip_arp_host($one_computer, q{*}, q{low}); # arp resolution
    11821182      next ALL_SWITCH if $resol_arp{mac_address} eq 'unknow';
    11831183
     
    14051405         $l++;
    14061406
    1407          print "\"location$b-$l\" [label = \"$building".'/'.join('\n',split(m{ / }xms, $loc))."\", color = black, fillcolor = orange, style = filled];\n";
     1407         print "\"location$b-$l\" [label = \"$building" . q{/} . join(q{\n}, split(m{ / }xms, $loc)) . "\", color = black, fillcolor = orange, style = filled];\n";
    14081408#         print "\"location$b-$l\" [label = \"$building / $loc\", color = black, fillcolor = orange, style = filled];\n";
    14091409         print "\"building$b\" -> \"location$b-$l\" [len = 2, color = firebrick]\n";
Note: See TracChangeset for help on using the changeset viewer.