smturner1 has asked for the wisdom of the Perl Monks concerning the following question:

I keep getting this error: "Can't modify scalar chomp in scalar assignment at deploy line 156, near "<STDIN> ;" Execution of deploy aborted due to compilation errors (#1) (F) You aren't allowed to assign to the item indicated, or otherwise try to change it, such as with an auto-increment." I cannot seem to figure out how to correct this issue. Any help would be much appreciated. Here is the subroutine that the error hit. The '<<' marks the line it errored on.
sub check_ok { my $str = shift; my $answer = shift; print "$str. Continue? y/n "; chomp ($answer) = <STDIN>; << die if 'N' eq uc $answer; if ( 'Y' ne uc $answer ) { print "Invalid response. Try again...\n"; check_ok($str); } return; }

Replies are listed 'Best First'.
Re: Compilation Error:
by choroba (Cardinal) on Jan 14, 2014 at 20:16 UTC
    You cannot use chomp as the left hand side of an assignment. You can, though, chomp the left hand side of an assignment:
    chomp($answer = <STDIN>);
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Compilation Error:
by toolic (Bishop) on Jan 14, 2014 at 20:24 UTC
    There's also:
    $answer = <STDIN>; chomp $answer;
Re: Compilation Error:
by Lennotoecom (Pilgrim) on Jan 14, 2014 at 20:16 UTC