in reply to Looping structure

I don't understand how you can't figure out what line the error is on. Read the error, it tells you:

tom@wintermute tom $ perl -c t syntax error at t line 17, near "else" t had compilation errors.
Reformatted code:
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"; }
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:
*** 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";
Update Reworded diff sentence to make it sound less harsh and more like original meaning.