What are you splitting $line on? The first argument to split is the delimiter to split on. The second argument is the scalar to split up. If it's unspecified, it defaults to $_, which is undefined in your examples. You probably want my @words = split ' ', $line; - try that out and see if it helps.
I want to commend you on using strict and warnings. Excellently done!
In general, if you think something isn't in Perl, try it out, because it usually is. :-)
"What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"