$VAR1 = { 'SPRequest' => { 'xrelease' => '13038', 'macaddr' => '47:00:11:22:00:30', 'name' => 'localhost', 'description' => 'demo' }, '.submit' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), 'class' => 'SPRequest', '22406' => { 'win.profile' => 'production', 'win.os_version' => 'standard', 'win.os_part_size' => '1' } }; #### my $form_data_file = "/tmp/${hostname}_${macaddr}.json"; open FH, ">$form_data_file" or die "Could not open $form_data_file. :$!\n"; print FH to_json( \%formdata, {pretty=>1} ); close FH; #### [red@tools-dev1 psong]$ cat /tmp/localhost_47-00-11-22-00-30.json { "SPRequest" : { "xrelease" : "13038", "macaddr" : "47:00:11:22:00:30", "name" : "localhost", "description" : "demo" }, ".submit" : true, "class" : "SPRequest", "22406" : { "win.profile" : "production", "win.os_version" : "standard", "win.os_part_size" : "1" } } #### my $form_data_file_csv = "/tmp/${hostname}_${macaddr}.csv"; # Text::CSV::Slurp wants arrayref of hashref my $ARoHR = [ \%formdata ]; my $csv = Text::CSV::Slurp->create( input => $ARoHR); open FH, ">$form_data_file_csv" or die "Could not open $form_data_file_csv. :$!\n"; print FH $csv; close FH; #### [red@tools-dev1 psong]$ cat /tmp/localhost_47-00-11-22-00-30.csv ; echo .submit,22406,SPRequest,class true,HASH(0x8d81918),HASH(0x8d67980),SPRequest