Leser: 9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#!/usr/bin/perl use warnings; use strict; sub checkRun { my @localtime = localtime(time()); my $wday = $localtime[6]; my $hour = $localtime[2]; # Monday to Thursday: if ($wday >= 1 && $wday <= 4) { return 1; } # Saturday: if ($wday == 6) { return 0; } # Sunday: if ($wday == 0) { if ($hour < 8) { return 0; } else { return 1; } } # Friday: if ($wday == 5) { if ($hour < 16) { return 1; } else { return 0; } } } print checkRun() . "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
use strict; use warnings; sub localtime{ my $self = shift; my $time = shift || time; my %hunt = (); my @fields = qw(sec min hour mday mon year wday yday isdst); @hunt{@fields} = localtime($time); $hunt{year} += 1900; $hunt{mon} += 1; return \%hunt; }; 1;######################################################################### #__END__ use Data::Dumper; $, = "\n"; my $m = bless{}; print Dumper $m->localtime(); $VAR1 = { 'wday' => 0, 'hour' => 13, 'min' => 0, 'isdst' => 0, 'sec' => 53, 'mon' => 12, 'yday' => 355, 'mday' => 22, 'year' => 2019 };