in reply to Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced?

Excellent feedback so far. The only thing I'd add is to lose the comments.

Let the code (ie. the proper naming of variables and function names) do the saying of what is happening. Comments should only be used to describe *why* something is happening. A comment in code should be a rather rare occurrence. If I see a comment in code, it's to point out why the following code is doing something that goes against the norm.

For example:

### execute command ### get the data $dbHandle=$db->prepare($dbCommand); $dbHandle->execute(); my $data = $dbHandle->fetchall_arrayref();

It's readily apparent that execute() and fetchall_arrayref() are performing the "execute command" and "get the data".

I know it's instinctive when first writing code to pepper it with comments, but trust me, if you practice without them, you'll become more efficient as a code reader and writer more quickly. It will force you to come up with more descriptive names for various items within your code.


my $var1 = 0; my $var2 = 1; # Draw an axis with a pencil and a ruler function($var1, $var2);


my $pencil = 0; my $ruler = 0; draw_axis($pencil, $ruler); sub draw_axis { my ($pencil, $ruler) = @_; if (! $pencil) { # On rare occasions, a pencil might be broken, so do this $pencil++; } }