firstly, all the best for the up and coming new year monks, secondly (script using strict and warnings as always :O) ) I have an hash of hashes with a pseudo structure as follows

$output{$mode}{category} $output{$mode}{division} $output{$mode}{priority} $output{$mode}{resolved} $output{$mode}{current} $output{$mode}{tis} $output{$mode}{customer} $output{$mode}{worker}

which can be printed out like below when each was just a single value but for keys "current" and "tis" I now have multiple values which I have joined up with a /n

for(sort keys %output) { print "$_,$output{$_}{category},$output{$_}{division},$output{$_}{ +priority},$output{$_}{resolved},$output{$_}{current},$output{$_}{tis} +,$output{$_}{customer},$output{$_}{worker}\n"; }

The list of which exists for say 'current' was populated with the following code <snippet>

while (m<CURRENT=(\S+)>gx) { $output{$mode}{current} = $1; push @{$cfg{$mode}{current}} => $output{$mode}{current +}; $output{$mode}{current} = join("\n",@{$cfg{$mode}{curr +ent}}); }

A dump of the hash now looks like this

$VAR1 = { 'AUTO' => { 'category' => 'Shelf', 'division' => 'deployment', 'priority' => '3', 'resolved' => 'YES', 'current' => 'CLOSED2/1 CLOSED2/2 CLOSED2/3 CLOSED2/4', 'tis' => '200 300 400 200', 'customer' => 'NO', 'worker' => 'YES', } };

How can I change my print statement so I can print as follows:

AUTO,Shelf,deployment,3,YES,CLOSED2/1,200,NO,YES AUTO,Shelf,deployment,3,YES,CLOSED2/2,300,NO,YES AUTO,Shelf,deployment,3,YES,CLOSED2/3,400,NO,YES AUTO,Shelf,deployment,3,YES,CLOSED2/4,200,NO,YES

Any help with this would be much appreciated


In reply to Printing hash values by Mark.Allan

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.