Perl编程实用技巧与用户交互优化
1. 避免保存有语法错误的Perl代码
在编辑Perl文件时,为了避免保存有语法错误的代码,可以使用特定的方法。在Vim中,使用 :W 代替 :w 来写入文件。如果文件使用 perl -c 编译失败,Vim将拒绝把文件写入磁盘。若要强制写入,可使用 :w 或 :W! 。
以下是相关代码:
" respect taint checking
if (match(getline(1), "^#!.\\+perl.\\+-T") == 0)
let command = command . " -T"
endif
exec "write" command
silent! cgetfile " try to read the error file
if !v:shell_error || a:do_anyway
exec a:do_command
set nomod
endif
endfunction
"" set up the autocommand, if b:perl_synwrite_au is true
if (b:perl_synwrite_au > 0)
let b:undo_ftplugin = "au! perl_synwrite * " . expand("%")
augroup perl_synwrite
exec "au BufWriteCmd,FileWriteCm
超级会员免费看
订阅专栏 解锁全文
72

被折叠的 条评论
为什么被折叠?



