<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Problems with my dictionary...that's been fixed.<br>
<br>
J. Shirley wrote:
<blockquote
cite="mid:756703690911181315j37898d7awc57fe6985bed186a@mail.gmail.com"
type="cite">
<div class="gmail_quote">Is it intentional, ironic or just amusing
that you are referring to Perl as "Pearl"? :)<br>
<br>
-J<br>
<br>
2009/11/18 Daniel Herrington <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:dherrington@robertmarktech.com">dherrington@robertmarktech.com</a>></span><br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
All,<br>
<br>
Hans, that deref was the problem, thanks. Verbosity tends to be a
holdover from when I was less secure in my Pearl coding and wanted to
know exactly what I did. I refactor towards verbosity when I run into
problems, which in this case didn't actually help solve anything. I was
actually using the following when i went to test and noticed the issue:<br>
<br>
push (@{$newBoxNameH{$newBoxName}}, $newJobName);<br>
<br>
This replaced that whole code snippet in B.<br>
<br>
Shlomi, thanks for the tips. The Code in snippet A was from over a year
ago, before I started getting serious with Pearl and learned about how
to handle complex data structure and dereferencing. I know I need to go
back and refactor the sub that A came from, and one day as God is my
witness I will ;) As always, time is the issue.<br>
<br>
The variable names aren't meant to be Hungarian, just simply how I
started with Pearl and identifying an array from a hash, etc. Now it's
just laziness as those names pop into my head when thinking of new
variables. I do like my variables to be somewhat related to the data
they contain, but it's an evolving standard in my head.<br>
<br>
Again, thanks all for the help and sorry for the double post.<br>
<br>
Dan H.
<div>
<div class="h5"><br>
<br>
Hans Dieter Pearcey wrote:
<blockquote type="cite">
<pre>Excerpts from Daniel Herrington's message of Wed Nov 18 10:12:07 -0500 2009:
</pre>
<blockquote type="cite">
<pre> my @arJobNamesB = $ref_arJobNamesB;
</pre>
</blockquote>
<pre>I bet you meant '@$ref_arJobNamesB'.
Your code would probably be easier to skim for this kind of thing if it were
less verbose. For example:
</pre>
<blockquote type="cite">
<pre> if ($newBoxNameH{$newBoxName}) {
my $ref_arJobNames = $newBoxNameH{$newBoxName};
my @arJobNames = @$ref_arJobNames;
push (@arJobNames,$newJobName);
$newBoxNameH{$newBoxName} = \@arJobNames;
} else {
my @arJobNames;
push (@arJobNames,$newJobName);
$newBoxNameH{$newBoxName} = \@arJobNames;
}
</pre>
</blockquote>
<pre> my @foo;
push @foo, $x;
$thing = \@foo;
can be much more easily written as
$thing = [ $x ];
In fact, the whole conditional I quoted above could be one line.
push @{ $newBoxNameH{$newBoxName} }, $newJobName;
Perl will automatically turn the nonexistent hash element into an array
reference for you. If this is too magical for your taste, default it to an
empty arrayref first:
$newBoxNameH{$newBoxName} ||= [];
hdp.
_______________________________________________
Pdx-pm-list mailing list
<a moz-do-not-send="true" href="mailto:Pdx-pm-list@pm.org"
target="_blank">Pdx-pm-list@pm.org</a>
<a moz-do-not-send="true"
href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a>
</pre>
</blockquote>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Pdx-pm-list mailing list<br>
<a moz-do-not-send="true" href="mailto:Pdx-pm-list@pm.org">Pdx-pm-list@pm.org</a><br>
<a moz-do-not-send="true"
href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a><br>
</blockquote>
</div>
<br>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
Daniel B. Herrington<br>
Director of Field Services<br>
Robert Mark Technologies<br>
<a class="moz-txt-link-abbreviated" href="mailto:dherrington@robertmarktechnologies.com">dherrington@robertmarktechnologies.com</a><br>
o: 651-769-2574<br>
m: 503-358-8575<br>
</div>
</body>
</html>