Help for this page

Select Code to Download


  1. or download this
    my @b = grep EXPR, @a;
    
  2. or download this
    my @b;
    foreach (@a) {
    ...
          push @b, $_;
       }
    }
    
  3. or download this
    my @uniqueIPs;
    foreach (@uniqueIPs) {
    ...
          push @ipAddresses, $_;
       }
    }
    
  4. or download this
    $x++
    
  5. or download this
    my $orig_x = $x;
    ++$x;
    $orig_x
    
  6. or download this
    my @uniqueIPs;
    foreach (@uniqueIPs) {
    ...
          push @ipAddresses, $_;  #    save it
       }
    }
    
  7. or download this
    my %counts;
    my @uniqueIPs = grep !$counts{$_}++, @ipAddresses;
    
  8. or download this
    my @uniqueIPs;
    foreach (@uniqueIPs) {
    ...
          push @ipAddresses, $_;  #    save it
       }
    }
    
  9. or download this
    # Remove duplicates IP addresses by counting
    # the number of times each address occurs.
    my %counts;
    my @uniqueIPs = grep !$counts{$_}++, @ipAddresses;
    
  10. or download this
    # Remove duplicates IP addresses by counting
    # the number of times each address occurs.
    my %counts;
    my @uniqueIPs = grep ++$counts{$_} == 1, @ipAddresses;