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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |