Hey all- I am new here for starters. I had a project where i need to write code in order to format certain astronomical databases for use later on in observation.

so here is an example of what the output should look like
233 NGC 188 - 233 0 38 40.024 85 00 21.93 F STATUS=OK

this is an example of what my code produces
12 NGC 188 - 12 6 6 31.217 85 33 30.70 O STATUS=OK
now what is important here is simply the numbers in the
middle which indicate Right Accension and Declination
the format output should look like (for example)
6 06 31.217 85 33 30.70
that zero attached to the front of the six is my problem, in my code, i am not sure how to make it so that way instead of a single digit _6(_ indicates a space), i can get an 06.

so here is the important code

while ($inline = <INPUT>) { #INPUT defined as variable# @firstline = split(/\s+/, $inline); #firstline of array defined by sp +lit of white space into variable inline# $hms1 = $firstline[2]; $hh1 = int ($hms1); $mm1 = int (60*( abs($hms1) - abs($hh1) ) ); $ss1 = 3600*abs($hms1) - 3600*abs($hh1) - 60*abs($mm1); $hms2 = $firstline[3]; $hh2 = int($hms2); $mm2 = int(60*( abs($hms2) - abs($hh2) ) ); $ss2 = 3600*abs($hms2) - 3600*abs($hh2) - 60*abs($mm2); $obid = "NGC 188 - $firstline[1]"; write; } close INPUT; format STDOUT = @>>> @<<<<<<<<<<<<<<<<<<< @# @# @#.### @# @# @#.## @ @<<<<<<<< $firstline[1], $obid, $hh1, $mm1, $ss1, $hh2, $mm2, $ss2, $cfo, $statu +s .
The there are three things happening in the loop. the loops involving converting into the variables $mm1, $ss1, etc creating the numbers that will go into the final format below. Again my question is where would i change my code so that way i could print out 06 instead of just _6(where _ indicates a space)?

I hope this makes sense what i am asking, if it does not, please let me know and i will attempt to reword it a little bit better.

thank you very much!
Steve


In reply to Formating question by srkaeppler

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.