Hey guys. I'm writing an LJ related script in which I need to keep a fairly large hash of data and have it persistent between page loads. I decided what I'd do is have a bunch of hidden fields of the format one_two_three_four_five which would equat to %DATA{"one"}{"two"}{"three"}{"four"}{"fi
So I went to write the first subroutine, the one that iters through the %FORM hash and parses the keys for inclusion in the %DATA hash that is being built. At this time ignore the fact that there may be keys in the %FORM hash that are unrelated.
Here's what I have right now:
$FORM{"bob_jones_rick_rudd"} = "one"; $FORM{"tree_house_shrub_bush"} = "two"; sub recurse_hidden { my $dataref = shift; # our hashref my $segment = shift; # segment of the blah_blah_blah_blah my $fullkey = shift; # full part of blah_blah_blah_blah if (! $dataref) { return ""; } if (! $segment) { return ""; } if ($segment =~ /^(\w+?)_.*/) { $segment =~ s/^$1_.*//; } if ($segment !~ /_/) { # we're at the end of the ladder $dataref->{$segment} = $FORM{$fullkey}; return %$dataref->{$segment}; } else { $dataref->{$1} = &merge_form($dataref{$1}, $segment, $fullkey); return %$dataref->{$1}; } } %DATA = &recurse_hidden(\%DATA);
So basically the problem is that the function doesn't work. I am pretty sure it's something stupid with my referencing, but I'm not quite sure. Would anyone mind taking a look at this and telling me what they think I'm doing wrong? Questions? Answers?