#!/usr/bin/perl -w

use strict;
use warnings;
use Switch;
use Term::ANSIColor;

my $date = '',my $ht = '',my $lt = '',my $bar = '',my $bardir = '',my $wind = '', my $ws = '', my $wg = '';
my $cloud = '', my $cc = '',my $rain = '', my $snow = '', my $hum = '', my $forcast = '', my $comm = '',my $line = '';

my $input = ' ';

while ($input ne '0')

{
  clear_screen();
	 print color('bold blue');
     print"Cool Dog Studio's Weather Base Work Sheet.\n";
     print color('reset');
     print color ('bold green');
     print"Enter Number to Edit, or 0 to Exit.\n\n";
     print color('reset');
     print"1 Work sheet Date\n",$date;
     print"2 Current High Temperature \n",$ht;
     print"3 Current low Temperature \n",$lt;
     print"4 Current Barometer\n",$bar;
     print"5 Barometer Direction\n",$bardir;
     print"6 Wind Direction... from\n",$wind;
     print"7 Wind Speed\n",$ws;
     print"8 Wind Gust\n",$wg;
     print"9 Cloud Type\n",$cloud;
     print"10 Cloudy Cover\n",$cc;
     print"11 Rain\n",$rain;
     print"12 Snow\n",$snow;
     print"13 Humidity\n",$hum;
     print"14 Forcast\n",$forcast;
     print"15 Comments\n",$comm;
     print color('bold red');
     print"16 Save Data to Disk\n";
     print"17 Load Data from File.\n";
     print color('reset');
     print color('bold yellow');
     print "Your Choice...";
     print color('reset');
     $input = <STDIN>;    
     chomp($input);

    switch ($input)
     {
        case '1'
         {
			 print "Enter Date ";
             $date = <STDIN>;
         }
       case '2'
        {
             print "Enter Current High Temperature.  ";
             $ht = <STDIN>;
        }
	   case '3'
	    {
	        print "Enter Current Low Temperature.  ";
	        $lt = <STDIN>;
	    }
	    case '4'
	    {
			print "Enter Barometric reading.  ";
			$bar = <STDIN>;
		}
		case '5'
		{
			print "Enter Barometer Direction.  ";
			$bardir = <STDIN>;
		}
		case '6'
		{
			print "Enter Wind Direction.  ";
			$wind = <STDIN>;
		}
		case '7'
		{
			print " Enter Wind Speed  ";
			$ws = <STDIN>;
		}
		case '8'
		{
			print "Enter Highest Wind Gust  ";
			$wg = <STDIN>;
		}
		case '9'
		{
			print "Enter Cloudy Type  ";
			$cloud = <STDIN>;
		}
		case '10'
		{
			print "Enter Cloudy Cover  ";
			$cc = <STDIN>;
		}
			case '11'
		{
			print" Enter Rain Fall  ";
			$rain = <STDIN>;
		}
		case '12'
		{
			print " Enter Snow Fall  ";
			$snow = <STDIN>;
		}
		case '13'
		{
			print "Enter Humidity  ";
			$hum = <STDIN>;
		}
		case '14'
		{
			print "Enter Forcast  ";
			$forcast = <STDIN>;
		}
		case '15'
		{
			print"Enter Comments  ";
			$comm = <STDIN>;
		}
		case '16'
		{
			#file save routine.
			unless (open(OUTFILE, ">wbwsdata"))
			{
				die ("cannot open output file outfile\n");
			}
			print OUTFILE ($date),($ht),($lt),($bar),($bardir),($wind),($ws),($wg),($cloud),($cc),($rain),($snow),($hum),
			($forcast),($comm);
			close (wbwsdata);
			#working good
		}
		case '17'
		{
		    #file load routine here
		    unless (open(INFILE, "<wbwsdata"))
		    {
				if (-e "wbwsdata")
				{
				    die ("File exists but cannot be opened\n");
				} else {
					die ("file does not exist.\n");
				}
			}
				$line = <INFILE>;
				while ($line ne "")
				{
					print "$line";
					$date = ($line);
					
					$line = <INFILE>;
				}
						
	    }
		
	}
}	
sub clear_screen
{
    system("clear");
}	




      

