in reply to Re: setting values in anonymous hash
in thread setting values in anonymous hash
I think that this method would make more sense to me if it went something like
I guess I'm just wondering why referring to hashes in a list context is a good idea.map { $_ = '' unless defined } values %$ref2;
Update: merlyn rightly points out this is a void usage of map. Perusing the docs for map led me to some insight. We want to test for values that are undefined and change them -- sounds like a job for grep:
fits the bill -- it actually acts on the returned values from grep, so no more void contexts, and actually reads like the task desired.for (grep {not defined} values %$ref2) {$_ = q()};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: setting values in anonymous hash
by Dominus (Parson) on Nov 28, 2000 at 22:27 UTC | |
by snax (Hermit) on Nov 28, 2000 at 22:40 UTC | |
by Dominus (Parson) on Nov 28, 2000 at 23:26 UTC | |
by snax (Hermit) on Nov 28, 2000 at 23:43 UTC |