in reply to Re^2: Print something when key does not exist
in thread Print something when key does not exist
Yes the !@F handles blank lines. When split, these will leave the @F array unpopulated, so scalar(@F) will be 0, or false, and the line gets skipped.
The %h is a Hash of Hashes. the outer "for sort keys %h" handles the first (outer) hash.
Inside that, I use a "hash slice" to get an array of values for keys specified by @w (which is a sorted array).
This is pretty much the same thing kcott does in his line:
except - my code does not worry about non-existing keys - since I run without 'warnings', my code does the right thing without complaint.map { $data{$name}{$_} || '' } @codes;
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^4: Print something when key does not exist
by jaypal (Beadle) on Apr 06, 2014 at 06:15 UTC |