[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Shell scripting
- Subject: [ale] Shell scripting
- From: fletch at phydeaux.org (Fletch)
- Date: 10 Feb 2003 10:26:35 -0500
>>>>> "David" == David S Jackson <dsj at sylvester.dsj.net> writes:
[...]
David> Hey perl gurus, how would you do a "uniq" in perl?
open( UNIQ, "| uniq > $outfile" ) or die "pipe to uniq failed: $!\n";
:)
If you mean naitively in perl, then you'd keep a hash of lines
already seen.
my %seen;
while( <FOO> ) {
next if $seen{ $_ }++;
## whatever . . .
}
If you're looking for uniq-ness on other than a line
granularity you'd of course need to extract whatever from the line
(using split(), a regex, index(), Astro::MoonPhase) and use that as
the key to your seen hash.
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
770 294-0820 (m) | scary questions." -- Jules =(___)=
| U
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale