Perl script to calculate the intersection of two lines