perl - Print hash of arrays with commas between the elements of the array -


i using

  $fields ( sort {$a<=>$b} keys %hoa) {        print "$fields-->@{$hoa{$fields}}\n";    } 

to print hash. output is:

0-->2132123 321321321 abcdefg 32 def ... 

i like:

0-->2132123,321321321,abcdefg,32,def,... 

is there way alter print statement give me commas? rather not use s/ /,/.

use explicit join.

for $fields ( sort {$a<=>$b} keys %hoa) {     print "$fields-->" . join (',', @{$hoa{$fields}}) . "\n"; } 

or localize version of $list_separator per perlvar

for $fields ( sort {$a<=>$b} keys %hoa) {     local $" = ',';     print "$fields-->@{$hoa{$fields}}\n"; } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -