in reply to Code fails without any reason?

As an aside, there's a couple interesting modules on CPAN: A number of implementations of different neural networks (including backpropagation networks) and bindings for libsvm (Support Vector Machines). They might save you a lot of time.

I know what I'm talking about -- In one project I spent too much time implementing Neural Networks in Java when there's already dozens of implementations out there :).