I had never heard of Time::Tiny before... If I understand its man page correctly, I think your code would create variable-length file names that might be hard to interpret reliably -- and might not be unique over the course of a day. That is, when you do:
my $timestring = $current_time->hour.$current_time->minute.$current_ti +me->second;
the time-stamp portion of each file name will range from "*.000.jpg" at midnight to "*.235959.jpg" at one second before midnight, with potential file-name collisions among sets of times like 01:23:45, 12:03:45 and 12:34:05 (which all would end up as "*.12345.jpg"), for example.

Personally, I'd use the POSIX "strftime" function to set up fixed-width (zero-padded) strings for the file names -- and while I'm at it, might as well throw in the "ymd" date as well. Also, I think I'd rather use less repetition in the literal strings (looks like there was an inconsistency in your file names: an extra "v" in "westconusvwv").

use strict; use LWP::Simple; use POSIX; my %image_url; for my $e_w ( qw/eastconus westconus/ ) { for my $typ ( qw/ir vs wv/ ) { $image_url{$e_w.$typ} = "http://www.goes.noaa.gov/GIFS/" . uc(substr($e_w,0,1)) . 'C' . $typ . '.JPG'; } } my $timestring = strftime( "%Y%m%d_%H%M%S", localtime ); print $timestring; for my $img ( keys %image_url ) { my $status = getstore( $image_url{$img}, join( '.', $img, $timestr +ing, 'jpg' )); print join( "\n", $img, $image_url{$img}, $status, "\n" ); }
For that matter, it would be even simpler if I decided that the original four-letter NOAA file names were good enough for me...

(updated the code to add a missing close-paren at line 16. Thanks, zentara!)


In reply to Re: Automated extraction of NOAA weather satellite images by graff
in thread Automated extraction of NOAA weather satellite images by Scott7477

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.