in reply to Print something when key does not exist
Update: FWIW, kcott's(++) detailed explanation below follows exactly the logic in my one-liner, that I was too lazy to document.perl -F/\\^/ -lanE 'next if $.==1 or !@F; $h{$F[0]}{$F[1]}=$F[2]; $v{$F[1]}++ } {say join ("^", "Name",@w=sort keys %v); say join ("^",$_,@{$h{$_}}{@w}) for sort keys %h' data1.txt
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print something when key does not exist
by jaypal (Beadle) on Apr 06, 2014 at 01:11 UTC | |
by NetWallah (Canon) on Apr 06, 2014 at 04:51 UTC | |
by jaypal (Beadle) on Apr 06, 2014 at 06:15 UTC |