in reply to meaning for the code
It pushes the first instance of each different item in @cn1_newnnn into the array @cn1_new and counts the number of repeats in %ss (assuming %ss is empty beforehand). Consider:
use strict; use warnings; my @cn1_new; my @cn1_newnnn = qw(apple orange grape apple lemon banana apple grape) +; my %ss; push(@cn1_new,grep {!$ss{$_}++} @cn1_newnnn); print "$_: $ss{$_}\n" for sort keys %ss; print "@cn1_new\n";
Prints:
apple: 3 banana: 1 grape: 2 lemon: 1 orange: 1 apple orange grape lemon banana
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: meaning for the code
by Util (Priest) on Dec 23, 2006 at 05:36 UTC |