Link to home
Start Free TrialLog in
Avatar of trevor1940
trevor1940

asked on

perl: Testing MGRS coordinates

Hi

I need to convert MGRS coordinates into digital Latitude Longitude

The metacpan module Geo::Coordinates::UTM  achieves this  by

($latitude,$longitude)=mgrs_to_latlon(23,'30VWK1254306804')

Open in new window



However if the MGRS coordinates  are incorrect it fails by crashing the script

How do I test the  MGRS coordinates prior to conversion? without killing the script but report error to user

Tried this but still crashes
if( ($latitude,$longitude)=mgrs_to_latlon(23,$mgrs) ){
  ## Do something with $mgrs
}
else{
 print "$mgrs incorrect in $InputDoc\n"
}

Open in new window



BTW I need to test all the  MGRS coordinates within the In put Doc so I can report it to the user
ASKER CERTIFIED SOLUTION
Avatar of Dave Cross
Dave Cross
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trevor1940
trevor1940

ASKER

Thanx both work going with Try::Tiny