Using the code you posted and the data above I get the answer:
2429
This code also gives the same answer:
#!/usr/bin/perl
use strict;
use warnings;
# 2429
my @row = do {
open my $lines, '<', 'input8.txt';
map [ /\d/g ], <$lines>;
};
my $visible = 198;
for my $current ( 0 .. $#row ) {
if ( $current > 0 && $current < 98 ) {
$visible += 2;
COUNT:
for my $i ( 1 .. 97 ) {
my $counter = 1;
while ( $row[ $current ][ $i - $counter ] < $row[ $current
+ ][ $i ] ) {
if ( ++$counter == $i ) {
++$visible;
next COUNT;
}
}
while ( $row[ $current ][ $i + $counter ] < $row[ $current
+ ][ $i ] ) {
if ( ++$counter == $i ) {
++$visible;
next COUNT;
}
}
while ( $row[ $current - $counter ][ $i ] < $row[ $current
+ ][ $i ] ) {
if ( ++$counter == $current ) {
++$visible;
next COUNT;
}
}
while ( $row[ $current + $counter ][ $i ] < $row[ $current
+ ][ $i ] ) {
if ( ++$counter == $current ) {
++$visible;
next COUNT;
}
}
}
}
}
print "$visible\n";