All pastes #280384 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-15 21:36 UTC
rendered paste body
#!/usr/bin/perl
print "\n" . "======================\n";
print "Scratch Alarm Ver. 0.1\n";
print "======================\n\n";
print "Please insert the song or directory of music you wish to wake up to.\n";
$song = <STDIN>;

@months = qw(1 2 3 4 5 6 7 8 9 10 11 12);
@weekDays = qw(1 2 3 4 5 6 7 1);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$year = 1900 + $yearOffset;
$theTime = "$hour:$minute:$second $months[$month]/$dayOfMonth/$year";

print "\n" . "The current time is...\n";
print "$theTime\n\n";
print "Please enter the month you would like to wake (number)\n";
$wake_month = <STDIN>;
print "Please enter the day you would like to wake\n";
$wake_day = <STDIN>;
print "Please enter the hour you would like to wake (on a 24 hour clock)\n";
$wake_hour = <STDIN>;
print "Please enter the minute you would like to wake\n";
$wake_minute = <STDIN>;
print "Please enter the year you would like to wake\n";
$wake_year = <STDIN>;


@current_second = "$second";
@current_minute = $minute * 60;
@current_hour = $hour * 60 * 60;
@current_day = $dayOfMonth * 24 * 60 * 60;
@current_year = $year * 360 * 24 * 60 * 60;
@current_time = "@current_second" + "@current_minute" + "@current_hour" + "@current_day" + "@current_year";

@wakeminute = $wake_minute * 60;
@wakehour = $wake_hour * 60 * 60;
@wakeday = $wake_day * 24 * 60 * 60;
@wakeyear = $wake_year * 360 * 24 * 60 * 60;
@wake_time = "@wakeminute" + "@wakehour" + "@wakeday" + "@wakeyear";

@sleep = "@wake_time" - "@current_time";
$wake_time2 = "$wake_hour:$wake_minute $wake_month-$wake_day-$wake_year";

print "Your alarm will go off in @sleep seconds";
system "sleep @sleep";
system "xmms -p $song";