in reply to Re: Thoughts on naming loop LABEL:
in thread Thoughts on naming loop LABEL:
I forgot to ask the probably greater question that AM points out below - *why* would one choose to LABEL: a loop?
cheers,
Update: Now that I've a bit of time, I'll try to es'plain my naming preference of singular-for-a-hash-var:
It seems to boil down to what looks more clear in the context of how I most commonly employ the variable types in my code. In the following bogo-code, each $hash{key} is dealt with as an individual (singular) item.
my %param = ( srcdir => '/home/me/perl/', destdir => '/root/perl/', moduledir => 'bar-foo', tarball => 'bar-foo.tgz', ); cd $param{srcdir}; system /usr/bin/tar $param{tarball} ¶m{moduledir} -zcvf and die $! +; system /bin/mv $param{tarball} $param{destdir} and die $!; cd $param{destdir}; system /usr/bin/tar $param{tarball} -zxvf and dir $!
Then in this next kind of hash usage, I still think of each $hash{key} as an individual item. And in the loop, the "keys" conveys the plurality of $hash{key}'s within the greater %hash. At least to me. Heh.
my %info = ( ' script' => "$0", ' executable' => "$^X $]", ' hostOS' => "$^O", ' starttime' => "$^T", ); for (keys %info) { print $_ $info{$key}, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (2) Thoughts on naming loop LABEL: (TMTOWTDI, why label loops?)
by cfreak (Chaplain) on May 02, 2002 at 15:02 UTC | |
|
Re (3): Thoughts on naming loop LABEL: (TMTOWTDI, why label loops?)
by VSarkiss (Monsignor) on May 02, 2002 at 15:04 UTC | |
by Anonymous Monk on May 02, 2002 at 17:06 UTC | |
by VSarkiss (Monsignor) on May 02, 2002 at 17:26 UTC |