in reply to Uniq and sort in perl
Any time you need to get a unique list in Perl you should think of using a hash. Say you defined a hash called %seen outside the while loop and changed the print line to read...
This will print the entry the first time and increment the seen flag for that pair, now subsequent identical results will encounter a set flag and not print as a resultprint "$vm, $filer, \n" if ! $seen{"$vm:$filler"}++;
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Uniq and sort in perl
by slayedbylucifer (Scribe) on Jul 12, 2012 at 09:22 UTC | |
by Anonymous Monk on Jul 12, 2012 at 10:51 UTC | |
by Preceptor (Deacon) on Jul 15, 2012 at 11:26 UTC |
In Section
Seekers of Perl Wisdom