Skip to content

Instantly share code, notes, and snippets.

@davorg
Created March 15, 2018 13:14
Show Gist options
  • Select an option

  • Save davorg/8baef67af1d5b4c8a8da6ae93fa67c59 to your computer and use it in GitHub Desktop.

Select an option

Save davorg/8baef67af1d5b4c8a8da6ae93fa67c59 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Storable;
my $hashref;
my $hash_file = 'hashfile';
if (-e $hash_file) {
$hashref = retrieve($hash_file);
} else {
$hashref = {};
}
if (@ARGV == 2) {
my ($newkey, $newval) = @ARGV;
$hashref->{$newkey} = $newval;
}
say "$_ -> $hashref->{$_}" for sort keys %$hashref;
store $hashref, $hash_file;
@davorg
Copy link
Author

davorg commented Mar 15, 2018

Pass two values to this program (a key and a value) to add a key/value pair to the persistent hash.

Don't pass any data to the program to just get a dump of the current data in the persistent hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment