#!/usr/bin/perl use strict; use warnings; use Astro::Coords; while (<DATA>) { # 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 (Op +t ) A [5.19 2.29 90] 2007A&A...474..653V Coordinates(ICRS,ep=J2000,eq=2000): 05 36 12.81335 -01 12 06.9089 (Op +t ) A [3.69 1.67 90] 2007A&A...474..653V Coordinates(ICRS,ep=J2000,eq=2000): 05 32 00.40009 -00 17 56.7424 (Op +t ) A [4.92 2.38 90] 2007A&A...474..653V
Output:
05 40 45.52666, -01 56 33.2649 
05:40:45.527, -01:56:33.26
85.1896944166667, -1.94257358333333
1.48684065633866, -0.0339043049914311

05 36 12.81335, -01 12 06.9089 
05:36:12.813, -01:12:06.91
84.0533889583333, -1.20191913888889
1.46700838478236, -0.0209774463163461

05 32 00.40009, -00 17 56.7424 
05:32:00.400, -00:17:56.74
83.0016670416667, -0.299095111111111
1.44865237452114, -0.00522019446550716

In reply to Re: wrapping bash and astronomy by Anonymous Monk
in thread wrapping bash and astronomy by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.