in reply to Automated downloading of NOAA radar images

I don't see $refresh changing in the loop, so I'm not sure why you have a do-while $refresh. If you just want an infinite loop, a naked block with a redo at the end will do nice.
  • Comment on Re: Automated downloading of NOAA radar images

Replies are listed 'Best First'.
Re^2: Automated downloading of NOAA radar images
by Scott7477 (Chaplain) on Jun 14, 2007 at 15:10 UTC
    Thanks for the tip, merlyn, I have "refactored" my code as follows:

    use strict; use LWP::Simple; use POSIX; my $refresh = 1800; { &imagegrab; sleep $refresh; redo; } sub imagegrab { my $base="http://radar.weather.gov/ridge/RadarImg/N0R/MTX_N0R_0.gi +f"; my $timestring = strftime( "%Y%m%d_%H%M%S", gmtime() ); my $savefilename = "SLCRadar_".$timestring.".gif"; my $status = getstore($base,$savefilename); print $status."\n" ; }

    It does seem a cleaner way to handle this...
(OT) Re^2: Automated downloading of NOAA radar images
by Argel (Prior) on Jun 18, 2007 at 21:28 UTC
    I know it doesn't really matter in this case but generally speaking isn't a while(1) block a better choice for infinite looping? I would think performance would be the same (I assume a while block collapses down to a naked-redo block) which leaves code readability. And letting the reader know at the beginning of the block that it's an infinite loop is a lot better than forcing the reader to wade through several lines of code before discovering that. Is that a good assessment or am I missing something?