choroba was right on about the ^ anchor. However, if you really just want to match any string exactly 8 characters long, why not use length?
my $LEN = 8; # Desired length
my $match;
while ($match = <STDIN>) {
chomp $match;
last if $LEN == length($match);
}
die "Didn't find a match" if not defined $input;
print "First match: '$match'\n";
More Less generally, you might use List::MoreUtils::firstval():
Update: as MidLifeXis points out, using firstval will require Perl to slurp in STDIN. This will be slower on files many megabytes large, or slow streams via pipelining. It will also never finish if STDIN never sees an EOF (again via pipelining). These may not be applicable to your situation, but choose carefully.
use List::MoreUtils 'firstval';
my $match = firstval { chomp; $LEN == length } <STDIN>;
The $LEN == length check could be replaced with anything you like. You can even pass in a code reference instead of the direct block, as in my $match = firstval \&my_match_sub, <STDIN>;