$c = $guess eq $answer;
This will take into consideration the exact string in your answer, and your answer has a newline half the time, and your guess both times. Also you have a space after 1 answer.
For example, lets say you guess "heads", then your $guess string will be:
$guess = "heads\n"; # newline added when reading with <>
Your answer will be either of these
$answer = "heads";
$answer = "tails \n";
So lets compare those...
# start end
# |heads\n|
# |heads|
# |tails \n|
As you can see, the only possible way for eq to be true is if you guessed "tails ", with an included space.
What you need to do is to clean up your input, and not have any newlines in your answer.
For example:
chomp(my $guess = <>); # remove newline from input
...
$answer = "heads";
...
$answer = "tails";
You can also strip whitespace and make the string the same case.
$guess =~ s/\s//g; # strip whitespace
$guess = lc($guess); # make lowercase
Also, note that writing Perl code without these two pragmas make your life excessively hard, so always include them:
use strict;
use warnings;