Created
March 15, 2018 13:14
-
-
Save davorg/8baef67af1d5b4c8a8da6ae93fa67c59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.