0
我試圖編寫一種方式,當用戶鍵入CTRL + C時,腳本將在關閉前執行幾個步驟。我知道如何在Python中做到這一點。 python代碼會是這樣的:Perl處理鍵盤中斷
try:
workbook = xlsxwriter.Workbook('Desktop\ODFU '+str(System)+'.xlsx')
worksheet = workbook.add_worksheet()
excelcreate(System)
login(USER, PASS)
test()
time.sleep(2)
print"Test is complete..."
logout()
except KeyboardInterrupt: # CTRL+C Terminates script and saves everything and logs out
print""
print "Interruption occurred!! Script terminating..."
workbook.close()
logout()
我怎樣才能得到與此完全一樣的Perl,但Perl?
感謝,我最終宣佈$ SIG { 'INT'} = '中斷';然後聲明子函數。 – bladexeon 2015-03-31 16:10:25