#!/usr/bin/perl use strict; use warnings; use Astro::Coords; while () { # Q3: How do I capture the 3 numeric fields for declination and # Right Ascension, dealing with the potential minus sign? # Ignore the details, capture non-whitepsace: /:\s(\S+)\s(\S+)\s(\S+)\s+(\S+)\s(\S+)\s(\S+)\s/; my $ra = "$1 $2 $3"; my $dec = "$4 $5 $6"; print "$ra, $dec \n"; # Q4: How do I do a sanity check on these values # without reinventing a wheel which someone else # has almost certainly created already? # Feed this module: my $c = Astro::Coords->new( ra => $ra, dec => $dec, type => 'J2000'); print # sexagesimal $c->ra( format => 'sex'), ", ", $c->dec(format => 'sex'), "\n"; print # degrees $c->ra( format => 'deg'), ", ", $c->dec(format => 'deg'), "\n"; print # radians $c->ra( format => 'rad'), ", ", $c->dec(format => 'rad'), "\n\n"; } __DATA__ Coordinates(ICRS,ep=J2000,eq=2000): 05 40 45.52666 -01 56 33.2649 (Opt ) A [5.19 2.29 90] 2007A&A...474..653V Coordinates(ICRS,ep=J2000,eq=2000): 05 36 12.81335 -01 12 06.9089 (Opt ) A [3.69 1.67 90] 2007A&A...474..653V Coordinates(ICRS,ep=J2000,eq=2000): 05 32 00.40009 -00 17 56.7424 (Opt ) A [4.92 2.38 90] 2007A&A...474..653V