I don't understand how you can't figure out what line the error is on. Read the error, it tells you:
Reformatted code:tom@wintermute tom $ perl -c t syntax error at t line 17, near "else" t had compilation errors.
You can't have two else blocks, so you probably meant to have an else block in the second if statement, like so:if ( exists $list{$location} ) { my $value = $list{$location}; $value++; $list{$location} = $value; } elsif ( $list{$location} eq "" ) { if ( exists $list{Unknown} ) { my $value = $list{Unknown}; $value++; $list{Unknown} = $value; } } else { $list{Unknown} = "1"; } else { $list{$location} = "1"; }
And just in case the difference isn't clear (kinda hard to see), here's a diff:if ( exists $list{$location} ) { my $value = $list{$location}; $value++; $list{$location} = $value; } elsif ( $list{$location} eq "" ) { if ( exists $list{Unknown} ) { my $value = $list{Unknown}; $value++; $list{Unknown} = $value; } else { $list{Unknown} = "1"; } } else { $list{$location} = "1"; }
Update Reworded diff sentence to make it sound less harsh and more like original meaning.*** 10,18 **** $value++; $list{Unknown} = $value; } ! } ! else { ! $list{Unknown} = "1"; } else { $list{$location} = "1"; --- 10,18 ---- $value++; $list{Unknown} = $value; } ! else { ! $list{Unknown} = "1"; ! } } else { $list{$location} = "1";
In reply to Re: Looping structure
by The Mad Hatter
in thread Looping structure
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |