#!/usr/bin/env perl use warnings; use strict; use JSON; my $history = 'history.json'; open my $fh, '<', $history or die $!; my $utf8_encoded_json_text = readline $fh; my $hashref = decode_json $utf8_encoded_json_text; close $fh; $hashref->{key_1} = [ 2, 3, 6, 11 ]; open $fh, '>', $history or die $!; $utf8_encoded_json_text = encode_json $hashref; print $fh $utf8_encoded_json_text; close $fh;