Changeset 165


Ignore:
Timestamp:
Jun 10, 2016, 5:52:27 PM (8 years ago)
Author:
g7moreau
Message:
  • Replace foreach by for loop
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r164 r165  
    264264   if ($ret{mac_address} ne 'unknow') {
    265265      my @paquets = ();
    266       foreach ( split m/ : /xms, $ret{mac_address} ) {
     266      for ( split m/ : /xms, $ret{mac_address} ) {
    267267         my @chars = split m//xms, uc "00$_";
    268268         push @paquets, "$chars[-2]$chars[-1]";
     
    374374   my @paquets = split m/ : /xms, $mac_address;
    375375   my $return = q{};
    376    foreach(@paquets) {
     376   for (@paquets) {
    377377      $return .= q{.} . digit_hex_to_dec($_);
    378378      }
     
    437437      # 21->24 45->48
    438438      SWITCH_PORT_IGNORE:
    439       foreach my $p (@{$sw->{portignore}}) {
     439      for my $p (@{$sw->{portignore}}) {
    440440         next SWITCH_PORT_IGNORE if $swport ne get_numerical_port($sw->{model},$p);
    441441         next LOOP_ON_SWITCH;
     
    11891189
    11901190   LOOP_ON_IP_ADDRESS:
    1191    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
     1191   for my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    11921192
    11931193#      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq 'unknow';
     
    12561256   my %mac_count = ();
    12571257   LOOP_ON_IP_ADDRESS:
    1258    foreach my $ip (keys %{$computerdb}) {
     1258   for my $ip (keys %{$computerdb}) {
    12591259
    12601260      # to be improve in the future
     
    12671267
    12681268   LOOP_ON_IP_ADDRESS:
    1269    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
     1269   for my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    12701270
    12711271      # to be improve in the future
     
    14451445   my %swithportdb = ();
    14461446   LOOP_ON_IP_ADDRESS:
    1447    foreach my $ip (keys %{$computerdb}) {
     1447   for my $ip (keys %{$computerdb}) {
    14481448      # to be improve in the future
    14491449      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
     
    14841484
    14851485   LOOP_ON_RECENT_COMPUTER:
    1486    foreach my $swpt (keys %swithportdb) {
     1486   for my $swpt (keys %swithportdb) {
    14871487      next LOOP_ON_RECENT_COMPUTER if $swpt =~ m/^\s*0$/;
    14881488      next LOOP_ON_RECENT_COMPUTER if $swithportdb{$swpt}->{hostname_fq} !~ m/$RE_FLOAT_HOSTNAME/;
     
    14911491      my $src_timestamp = 0;
    14921492      LOOP_ON_IP_ADDRESS:
    1493       foreach my $ip (keys %{$computerdb}) {
     1493      for my $ip (keys %{$computerdb}) {
    14941494         next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{mac_address} ne  $swithportdb{$swpt}->{mac_address};
    14951495         next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} =~ m/$RE_FLOAT_HOSTNAME/;
     
    17311731
    17321732   LOOP_ON_IP_ADDRESS:
    1733    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
     1733   for my $ip (Net::Netmask::sort_by_ip_address(keys %{$computerdb})) {
    17341734
    17351735      next LOOP_ON_IP_ADDRESS if $computerdb->{$ip}{hostname_fq} eq ($computerdb->{$ip}{switch_hostname} || $computerdb->{$ip}{switch_description}); # switch on himself !
     
    17951795            my $mac_address = $computerdb->{$ip}{mac_address};
    17961796            LOOP_ON_DATABASE:
    1797             foreach my $ip_db (keys %{$computerdb}) {
     1797            for my $ip_db (keys %{$computerdb}) {
    17981798               next LOOP_ON_DATABASE if $computerdb->{$ip_db}{mac_address} ne $mac_address;
    17991799               next LOOP_ON_IP_ADDRESS if $computerdb->{$ip_db}{timestamp} > $timestamp_barrier;
     
    18331833   print "-------------------------------------------------------------------------------\n";
    18341834   LOOP_ON_IP_ADDRESS:
    1835    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
     1835   for my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
    18361836         printf "%-15s %-40s %-16s %s\n", $ip, $result_ip{$ip}->{hostname_fq}, $result_ip{$ip}->{date_last_detection}, $result_ip{$ip}->{vlan};
    18371837      }
     
    18661866
    18671867   LOOP_ON_IP_ADDRESS:
    1868    foreach my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
     1868   for my $ip (Net::Netmask::sort_by_ip_address(keys %result_ip)) {
    18691869
    18701870      $typerow = $typerow eq 'even' ? 'odd' : 'even';
Note: See TracChangeset for help on using the changeset viewer.