$1 is the first bracketed match in a regular expression, you don't want that.
Why didn't you write simply
my $predict = $_?
Another suggestion: use the 3 argument form of
open.
if ($train = $predict) is also wrong: You have to use
== when checking.
I'm too lazy to be proud of being impatient.