summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-07-12 14:47:50 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-07-12 14:47:50 +0200
commit4995165edcb08e2f364bfc7fc42d2f65bcd069c0 (patch)
tree438dfe9198f9ea084779a5303135692c67bdbf0e
parentc9f8a8aa21c2804701d678afe5d05512df789617 (diff)
Simplestore: Allow only \w+ key names
-rw-r--r--lib/Simplestore.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Simplestore.pm b/lib/Simplestore.pm
index 11d8058..35c94e2 100644
--- a/lib/Simplestore.pm
+++ b/lib/Simplestore.pm
@@ -37,6 +37,9 @@ sub save {
my $key;
open(my $handle, '>', $file) or confess("Cannot open $file: $!");
foreach $key (keys(%$store)) {
+ if ($key !~ /^\w+$/) {
+ confess("Invalid key name: May only contain alphanumeric and _");
+ }
foreach (split(/\n/, $store->{$key})) {
print $handle "$key\t$_\n";
}
@@ -78,8 +81,9 @@ Simplestore - simple storage format for hash refs
B<Simplestore> is a perl library to store hashes in a very simple,
easy-to-parse file format.
-Note that it can only store simple hashes with string/digit values.
-References or any other complex stuff is not supported.
+Note that it can only store simple hashes with string/digit values and
+word keys (the key must match \w+, like a perl variable name for example).
+References or any other complex stuff are not supported.
=head1 FUNCTIONS