#!/usr/bin/env perl use 5.030; use warnings; use Storable; my ($hashfile, $serial_data_for); INIT { $hashfile = 'pm_11148149_storable_first_run.sto'; $serial_data_for = -e $hashfile ? retrieve($hashfile) : {}; } my @keys = qw{key1 key2 key3}; my @vals = qw{data1 data2 data3}; $serial_data_for->@{@keys} = @vals; store($serial_data_for, $hashfile); #### #!/usr/bin/env perl use 5.030; use warnings; use Storable; use Data::Dump; warn "Perl version: $^V\n"; my ($hashfile, $serial_data_for); INIT { $hashfile = 'pm_11148149_storable_first_run.sto'; $serial_data_for = -e $hashfile ? retrieve($hashfile) : {}; } say 'Serialised data:'; dd $serial_data_for; my @keys = qw{key1 key2 key3}; my @vals = qw{data1 data2 data3}; $serial_data_for->@{@keys} = @vals; store($serial_data_for, $hashfile); #### ken@titan ~/tmp $ rm pm_11148149_storable_first_run.sto ken@titan ~/tmp $ ls -l pm_11148149_storable_first_run.sto ls: cannot access 'pm_11148149_storable_first_run.sto': No such file or directory ken@titan ~/tmp $ ./pm_11148149_storable_first_run_1.pl Perl version: v5.30.0 Serialised data: {} ken@titan ~/tmp $ ls -l pm_11148149_storable_first_run.sto -rw-r--r-- 1 ken None 69 Nov 12 13:00 pm_11148149_storable_first_run.sto ken@titan ~/tmp $ ./pm_11148149_storable_first_run_1.pl Perl version: v5.30.0 Serialised data: { key1 => "data1", key2 => "data2", key3 => "data3" } ken@titan ~/tmp $ #### sub DoIHaveThisData { my ($hash, $key) = @_; return exists $hash->{$key}; }