Hello adamadamson, and welcome to the Monastery!
Building on roboticus’s answer: I believe there are actually three typos: one misspelling, one missing semicolon, and one wrong sigil ($ instead of %).
I suggest that your next step should be to take the line:
my (%added, $field, $found, $key, $record, @records, @results, $return
+ed, %superceded, $originalid, $value);
and move each variable declaration to the point in the code where it’s actually needed. (This may be the point where it’s first used, or it may be a point before that — see e.g. Coping with Scoping). When you do this, you will find that only one of these 11 variable declarations needs to be on this line in the code; and one isn’t needed at all (because it’s never used).
You should also give careful consideration to your variable names. Having a scalar variable named $supercede (which appears to be a hash reference), and a hash variable named %superceded, is a recipe for confusion.
By the way, when you have a structure like this:
if (...) {
...
} else {
if (...) {
you can in many cases reduce indentation, and so make the code easier to read, by using Perl’s elsif construct (see Compound Statements):
if (...) {
...
} elsif (...) {
Hope that helps,
|