in reply to How could I simplify this redundant-column-removing code?

My version:

#! perl -sw use strict; my $pos = tell DATA; my %tally; ++$tally{ $_ } for map split( '&' ), <DATA>; my $lines = $.; seek DATA, $pos, 0; print join '&', grep{ $tally{ $_ } != $lines } split '&' while <DATA> __DATA__ a=1&b=1&c=1&d=2&e=&f=3 a=1&b=2&c=3&d=2&e=&f=4 a=1&b=2&c=5&d=1&e=&f=5

Produces:

C:\test>junk b=1&c=1&d=2&f=3 b=2&c=3&d=2&f=4 b=2&c=5&d=1&f=5

For a real file, you wouldn't need the tell, just rewind the file with seek $fh, 0, 0; for the second pass.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked