#!/usr/bin/perl -w ### # The latest version of my diary program ### use strict; use POSIX 'strftime'; # declare the variables my @diary = "/path/to/diary/diary.txt"; my $filename=strftime("/path/to/diary/%m-%d-%Y.entry.txt",localtime); my ($minute, $hour, $day, $month, $year) = (localtime)[1,2,3,4,5]; # format the time properly $month++; $year += 1900; # open the files for writing/appending open FILE, ">>$filename" or die "Can't open file: $!\n"; open DIARY, ">>@diary", or die "Can't open file : $!\n"; # put the time in the diary, time and weather in the date page printf DIARY ("%02d\/%02d\/%04d %02d\:%02d \n", $month, $day, $year, $hour, $minute); printf FILE ("%02d\:%02d \n", $hour, $minute); weather(); # write the diary entry print "Go ahead and write. Hit ^D to end. \n"; @diary = ; print FILE "@diary \n"; print DIARY "@diary \n"; # close the files close(FILE); close(DIARY); # the weather subroutine sub weather { use Geo::Weather; my $weather = new Geo::Weather; my $current = $weather->get_weather('07060'); print FILE "Temperature in Plainfield, NJ\: $current->{temp} degrees\n\n"; }