use warnings; use strict; use JSON; my @array = qw(1 2 3); open my $wfh, '>', 'file.ext' or die "can't open file for writing: $!"; print $wfh encode_json(\@array); close $wfh; open my $fh, '<', 'file.ext' or die "can't open file for reading: $!"; my $aref = decode_json(<$fh>); close $fh;