Hi Monks, I've updated the code snippet so hopefully it's more clear. I'm stuck trying to dereference an array of hashes. Each key has 2 values (normally a hash consists of one key and one value...so this is confusing me a little bit.
For example, I have several managers (the key) that have 2 values for each ..."total events" and "total updates"
my @mans = qw / Joe Mike Rich /;
my @tot_updates = qw /12 7 17 /;
my @tot_events = qw /45 14 10 /;
for (@mans) {
push( @{$managers{$_}}, shift@tot_updates);
push( @{$managers{$_}}, shift@tot_events);
}
for $t ( $#managers ) {
for $b ( keys %{$managers[$t]}) {
print "$t and $b is $managers[$t]{$b}\n";
}
}
Pushing the values onto the array works fine i believe. It's dereferencing that's not working. I'm totally confused how to dereference this...I'd like the output to be:
manager: value1(total updates) value2(total events)
Joe 12 45
Mike 7 14
Rich 17 10
Please help if you can..I would really appreciate it greatly
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|