Perl script to calculate intersection of two lines