#!/usr/bin/perl

# by -Sx- :: Run this as cron -
#            0 0 * * 1 /usr/bin/MoonPhases > /dev/null 2>&1
#
# ... the code was designed for my site, but you could adapt the HTML to your needs...
#
# The main logic - minus the HTML:
#
#	use Astro::MoonPhase;
#	my @phases = phasehunt();
#	print "New Moon      = ", scalar(localtime($phases[0])), "\n";
#	print "First quarter = ", scalar(localtime($phases[1])), "\n";
#	print "Full moon     = ", scalar(localtime($phases[2])), "\n";
#	print "Last quarter  = ", scalar(localtime($phases[3])), "\n";
#	print "New Moon      = ", scalar(localtime($phases[4])), "\n";
#

use Astro::MoonPhase;

my $dataLine;
my @phases = phasehunt();

$dataLine .= "<LI>New Moon :: &nbsp;"      . scalar(localtime($phases[0])) . "\n";
$dataLine .= "<LI>First quarter :: &nbsp;" . scalar(localtime($phases[1])) . "\n";
$dataLine .= "<LI>Full moon :: &nbsp;"     . scalar(localtime($phases[2])) . "\n";
$dataLine .= "<LI>Last quarter :: &nbsp;"  . scalar(localtime($phases[3])) . "\n";
$dataLine .= "<LI>New Moon :: &nbsp;"      . scalar(localtime($phases[4])) . "\n";

$homeDir	= '/usr/local/Forsaken/Perl_Code/1/src';
$fileName	= '/moonPhases.html';

open (SXFILE, ">$homeDir$fileName") or die "Cannot open handle for $homeDir$fileName ... $!";

print SXFILE<<_PrimaryHTML_;
<HTML>
<HEAD><TITLE>Moon Phases Jacksonville, Fl</TITLE></HEAD>
<BODY BGCOLOR=990000 TEXT=FFFFFF LINK=FFCC00 VLINK=FFCC00 ALINK=FFFFCC 
      MARGINHEIGHT=0 MARGINWIDTH=0 TOPMARGIN=0 BOTTOMMARGIN=0 LEFTMARGIN=0 RIGHTMARGIN=0>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td valign="top"> Moon Phase for Jacksonville, Florida ... by -Sx- </td>
  </tr><tr><td>
    <table width="100%" border="0" cellspacing="0" cellpadding="10">
      <tr><td><font size="2" face="Trebuchet MS, Arial, Helvetica">

$dataLine

      </font></td></tr>
    </table>
  </td></tr><tr><td valign="bottom"><a href="javascript:self.close();">
  <img src="/closeW.png" width="223" height="41" border="0"></a></td></tr>
</table></BODY></HTML>

_PrimaryHTML_

close (SXFILE) or die "Cannot close handle for $homeDir$fileName ... $!";

__END__
