[tpm] hash naming convention: singular or plural
Madison Kelly
linux at alteeve.com
Fri Aug 8 07:51:56 PDT 2008
Alexander Anderson wrote:
> Hello Toronto Perl Mongers,
>
> Names of scalars are usually singular, for example,
>
> $month = 'Aug';
>
> Names of arrays are usually plural, for example,
>
> @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
>
> How do you name your hashes, for example,
>
> %months = ( Jan => 1, Feb => 2, ..., Dec => 12 );
> or
> %month = ( Jan => 1, Feb => 2, ..., Dec => 12 );
>
> Thanks.
Personally, I tend to use singular as I more often type the hash with
the key, so it makes more sense to say "$month{'Aug'}" many times over
'my %months=()' once.
Personal preference though, of course. I do the same for SQL tables and
such, with a few notable exceptions (ie: 'users' instead of 'user',
which usually has an internal value).
Madi
More information about the toronto-pm
mailing list