in reply to What's wrong with this code? PERL HELP!

adamadamson:

It would be hard to tell what's wrong with the code unless we know what it's supposed to do. You really need to provide context! Error messages, sample data, sample output, etc., would go a long way towards making your question something people might try to answer.

Just for anyone who cares, I reformatted your code below. However, after reformatting your code, I only saw two typos that you could've found yourself had you added use warnings; and use strict; to your program. Other than those, I didn't see anything painfully obvious.

Without a clue as to what it is supposed to do, though, I'm not going any further. Yeah, I *could* try to analyze the code to figure out what it's supposed to do. But since you already *know* what it's supposed to do, I needn't waste my time on that.

sub supercede { my $self = shift; my $records = shift; my $supercede = shift; my $ignore = shift; my (%added, $field, $found, $key, $record, @records, @results, $ret +urned, %superceded, $originalid, $value); foreach $returned (@{$records}) { foreach $field (keys %$supercede) { if ($returned->{$supercede->{$field}}) { foreach $key (keys %{$records}) { if (!grep(/^$key/, @{$ignore})) { $superceded{$returned->{$supercede->{$field}}}- +>{$key} = $retruned->{$key}; } else { if (!$superceded{$returned->{$field}}) { $found = 0; foreach $record (@{$records}) { if ($record->{$field} == $returned->{$s +upercede->{$field}}) { $found = 1 last; } } if ($found == 0) { $superceded{$returned->{$supercede->{$f +ield}}}->{$key} = $returned->{$key}; } } } } } else { if (!$superceded{$returned->{$field}}) { $superceded{$returned{$field}} = $returned; } } } } foreach $value (values $superceded) { if (!$added{$value}) { push @results, $value; $added{$value} = 1; } } return @result; }

...roboticus

When your only tool is a hammer, all problems look like your thumb.