in reply to Re: What to test in a new module
in thread What to test in a new module
Reduce a ton of noise by eliminating quotes in hash keys when they don't contain anything other than alphanum and underscore. This: $vars{'error'} becomes this: $vars{error}
The reasons I single quote hash keys are:
I think of 3 in the same way I been told that:
is better than:if ($condition) { $var = 1; }
because we might want to add another statement into the code block.$var = 1 if $condition;
Likewise, I feel:
is better than:$vars{'example'} = 1;
because we can expand it easily if necessary and create something like:$vars{example} = 1;
$vars{'example' . $count} = 1;
Others may have different opinions, clearly they do as there is a lot of code with unquoted hash keys, but this works for me in terms of clarity, expandability and maintainability. I don't see any downside to is on performance (please correct me if there is!) so I think I shall keep this one the way it is.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quoted hask keys (was: Re^2: What to test in a new module)
by Tux (Canon) on Jul 09, 2023 at 09:27 UTC | |
by hippo (Archbishop) on Jul 09, 2023 at 11:21 UTC | |
|
Re: Quoted hask keys (was: Re^2: What to test in a new module)
by tobyink (Canon) on Jul 10, 2023 at 08:43 UTC |