2011-07-08 50 views

回答

3

你可以在$ HOME/.perldl_hist

你的歷史記錄,這可能是也可能不是依賴於具有安裝期限:: ::的ReadLine羚(這是我在默認情況下)。

如果您想要在pdl以內訪問您的歷史記錄,那麼只需使用上箭頭鍵查看先前的命令,或者鍵入^ R(control-r),然後輸入您想要搜索的文本(重複執行^ r爲進一步匹配)。

$ pdl 
perlDL shell v1.354 
...blah blah blah... 
pdl> print 1+1 
2 
pdl> print 2+2 
4 
pdl> quit 

$ cat ~/.perldl_hist 
print 1+1 
print 2+2 
$ 

編輯:要找到內史pdl,請執行下列操作:

$ pdl 
pdl> print join "\n", $PERLDL::TERM->GetHistory 

$PERLDL::TERM->GetHistory返回當前歷史的數組。這只是一個普通的數組,所以你可以隨心所欲地做任何事情。例如,要查找所有涉及到一個名爲mypdl小罐最近直方圖操作,你可以這樣做:

pdl> print join "\n", grep { /histogram/ && /mypdl/ } $PERLDL::TERM->GetHistory 
+1

感謝。我忘記了hist文件。我想列出pdl2中的歷史記錄,以瞭解我以前在繼續編碼之前所做的工作,並忘記了'^ z cat ...'的可能性。那麼下一次,如果我真的想在pdl2中看到它,我總是可以做'pdl> print qx {cat〜/ .perldl_hist}'。 –

+1

這種方法的問題是,我想查看當前會話的歷史記錄而不退出!!那可能嗎?當前會話歷史記錄僅在退出後添加到.perldl_hist。 –

+1

@Pablo - 我已經更新了答案,以從「pdl」中獲取信息。請注意,您必須安裝「Term :: ReadLine :: Gnu」(首選)或「Term :: ReadLine :: Perl」。 – unpythonic

1

從PDL文件(即pdldoc perldl):

History mechanism 
    If you have the perl modules ReadLines and ReadKeys installed, then 
    perldl supports a history and line-editing mechanism using editing keys 
    similar to emacs. The last 500 commands are always stored in the file 
    .perldl_hist in your home directory between sessions. Set 
    $PERLDL::HISTFILESIZE to change the number of lines saved. The command 
    "l [number]" shows you the last "number" commands you typed where 
    "number" defaults to 20. 
+0

在'pdl2' shell中開發了一種計算方法後,您可以複製.perldl_hist文件並進行編輯以生成腳本/程序來執行相同操作。 – chm

相關問題