sub f
{
        my $x = shift;

        return ($x * $x * $x - 3*$x*$x + 2*$x);
}

my $step = 0.001; 
my $start = -1;
my $stop = 3;
my $value = &f($start);
my $sign = $value > 0;



print "Root found at $start\n" if ( 0 == $value );

for(    my $x = $start + $step;
        $x <= $stop;
        $x += $step )
{
        $value = &f($x);

        if ( 0 == $value )
        {
                
                print "Root found at $x\n";
        }
        elsif ( ( $value > 0 ) != $sign )
        {
                
                print "Root found near $x\n";
        }

        
        $sign = ( $value > 0 );
}