G'day SamCG,

A small, representative example of data, together with a short, self-contained script that reproduces what you're attempting to achieve, would go a long way to getting a better answer. If terms such as "parties", "transactional roles", "production values", and so on, are important in understanding your problem domain, please provide appropriate descriptions.

"... but I still think it could be improved"

Here's some suggestions for improvement (particularly with respect to readability and maintainability).

Using statements, as opposed to simple values, for the ternary operators's 2nd and 3rd operands, leads to all sorts of problems (often related to precedence), reduces readability, and increases the difficulty of maintenance: all of this leads to error-prone code. See the documentation (link provided) for examples.

This

exists $uat_tid{$key}?print "$uat_tid{$key}\t":print "No UAT trans id\ +t";

would probably be better as

print exists $uat_tid{$key} ? $uat_tid{$key} : 'No UAT trans id', "\t" +;

And this

exists $uat->{$key}{$inrole}?print "$uat->{$key}{$inrole}":for my $rol +e_key ( keys %{$uat->{$key} } ) { print $role_key if $uat->{$key}{$role_key} eq $value};

would definitely be better as

if (exists $uat->{$key}{$inrole}) { print $uat->{$key}{$inrole}; } else { for my $role_key (keys %{$uat->{$key}}) { print $role_key if $uat->{$key}{$role_key} eq $value; } }
"Does the code below work?"

I don't really know what you're asking. Short answer: run it and find out for yourself. Longer answer: explain what it's supposed to do and why the "Short answer" is inadequate.

"And if so, can I really insert it the way I did into the trinary operator above?"

As already explained, even attempting to do so is not a good idea.

-- Ken


In reply to Re: Iterating over second key in HoH defined by reference by kcott
in thread Iterating over second key in HoH defined by reference by SamCG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.