#!/usr/bin/env perl -- use strict; use warnings; use JSON (); use WWW::Mechanize 1.72; Main( @ARGV ); exit( 0 ); sub Main { my $data = { a => 40, b => 2 }; my $json = JSON->new->utf8; my $ua = WWW::Mechanize->new; $ua->post( "http://myurl/public_html/cgi-bin/json-addition.cgi", Content_Type => 'application/json', Content => $json->encode($data), ); $ua->res->dump; if( $ua->is_json ){ my $result = $json->decode( $ua->content ); print $result->{c}, "\n"; } } sub WWW::Mechanize::is_json { int( 'application/json' eq $_[0]->ct ) }