in reply to Re: How not to write subroutines
in thread How not to write subroutines
# code to mimic uniq(1)
# mode: divine my @result = do { my %counter; grep ++$counter{$_} == 2, @input; };
(And yes, both example stolen from Get All Duplicated Elements in an Array (Once, without shifting), and I mean absolutly nothing with the different modes.)# mode: tired for (@input) { $multiples{$_}++; } for keys( %multiples ) { print "$_\n" if (--$multiples{$_}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How not to write subroutines
by gustavderdrache (Acolyte) on Jan 15, 2006 at 15:38 UTC |