You've got the program at the wrong end of the pipe. You opened a pipe for inputting to from.pl. It's also not clear whether from.pl has the proper #! line and execute permissions.
Try this instead:
open(P, "perl from.pl |") or die "Can't pipe from from.pl: $?\n";
while (<P>) {
print $_;
$count++;
}
close(P) or die "Can't pipe from from.pl: $?\n";
print "$count\n";