我想編寫腳本來自動幫助我預訂網站的時間段。由於我想預訂週一至週五,我寫的腳本會彈出瀏覽器中的五個選項卡system("start $book")
我可以在完成預訂後關閉選項卡嗎?以下是我的示例代碼。使用perl打開和關閉網頁
use Time::Local;
use POSIX;
####### this week ##########
my $today = time();
my $seconds = 24*60*60;
my @gmtime = gmtime();
[email protected];
$today = $today - $gmtime[6] * $seconds;
for my $haha (0..4) {
$today += $seconds;
my @wday = gmtime ($today);
push @thisweek,strftime ("%Y%m%d %Y%U", @wday);
}
($monday_1,$tuesday_1,$wednesday_1,$thursday_1,$friday_1) = @thisweek;
book_time($monday_1,"1617");
book_time($tuesday_1,"1617");
book_time($wednesday_1,"1617");
book_time($thursday_1,"1617");
book_time($friday_1,"1617");
sub book_time()
{
my ($bookdate,$bookweek)= split " ",shift;
my $booktime= shift;
my $book = "http://www.example.com";
system("start $book");
}
爲什麼不使用[Win32 :: OLE](http://search.cpan.org/~jdb/Win32-OLE-0.1712/lib/Win32/OLE.pm),那麼你可以完成後退出? –
嗨@GerhardBarnard,我是perl中的新成員,不知道如何在腳本中使用這個'Win32 :: OLE',你能告訴我一個例子嗎?謝謝 – Tim
在下面的答案中看到一個簡單的演示。您可以在[Win :: OLE](http://search.cpan.org/~jdb/Win32-OLE-0.1712/lib/Win32/OLE.pm)頁面找到更多幫助 –