in reply to Lagrange Polynomials in Perl

Have you inspected the values your functions receive? How are you calling your functions?

my @x = shift;

This is unlikely to do what you might think it does.

Perl flattens arrays when passing them to a function:

sub foo { my( @x, @y )= @_; }; foo( @a, @b );

The above code will always end up with @x containing all elements of @a and @b, and @y will always be empty.