By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

Is this an efficiency hack of some sort?

P: n/a

I'm updating a fairly old Perl script. Before I change what seems to
be a strange practice, I want to be sure the original author wasn't
exploiting some efficiency trick.

The hash %foo is used only within a subroutine, but rather than declare
it in the subroutine, he declares it in the global context and passes a
reference to it into the subroutine:


my %foo;
sub processData {
my $fooRef=@_[0]; # he doesn't like "shift".
// do stuff with $$fooRef{}

Again, the hash is not used outside of the subroutine, and there's no
reason to believe that it ever would have been. He actually does
this with several different hashes.

The reason I'd like to do away with it is that within the subroutine,
each time he reads a new line of data from a file, he loops through
(keys %{$fooRef}) deleting each one. There are quite a few, so I'd
rather just undef the hash and build it again.


Feb 22 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.