Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear Perl Monks. I have collected bunch of arrays that first element of each array should be a key I would like to produce print out like bellow. Do you have more elegant solution ? I will appreciate
ArrA = qw(A 1 2 3 4 5); ArrB = qw(B 1 2 5 6); ArrC = qw(C 2 3); for ($i=1; $i < 6; $i++) { push(@{$CAPABILITIES{$ArrA[$i]}}, $ArrA[0]); push(@{$CAPABILITIES{$ArrB[$i]}}, $ArrB[0]); push(@{$CAPABILITIES{$ArrC[$i]}}, $ArrC[0]); } foreach $key (sort (keys %CAPABILITIES)) { print "$key => "; foreach $role (sort @{$CAPABILITIES{$key}}) { print "$role "; } print "\n"; } # Desired Printout =begin COMMENT Key/Value ====================== 1 => A B 2 => A B C 3 => A C 4 => A 5 => A B 6 => B OR Key/Value A B C ====================== 1 X X 2 X X X 3 X X 4 X 5 X X 6 X =end COMMENT =cut
(: Life is short enjoy it :)

In reply to Multiple arrays in a hash by gasho

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

  • 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.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-06-07 21:36 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.