Quicker is really unlikely to be an issue. "Better" is much harder to define. You may consider one of:
$_ //= '' for values %foo;
$foo{$_} //= '' for keys %foo;
"better". I'd tend toward the first because it's maybe a little more obvious that it's the values in the hash that you are processing.
For the most part when thinking about "better", think about "is the intent of this code obvious?". Make the code clear first, then if you really need to, make it faster. Almost always you don't need to do the "make it faster" bit.
If you do think you need to make it faster, first write unit tests then profile the code before changing anything. Unit tests to make sure you don't break the code while changing it. Profile so you don't waste your time "fixing" stuff that isn't broken.
Perl is the programming world's equivalent of English
|