perl use vars pragma使用技巧
perl 中的vars是perl中的一個pragma(預編譯指示符),專門用來預定義全局變量,這些預定義后的全局變量在qw()列表中,在整個引用perl文件中皆可使用,即便使用use strict也不會報錯:
use strict ;
$str = "hello world!\n" ;
報錯信息:Global symbol "$str" requires explicit package name at ~vars.pl line 3.
Execution of ~vars.pl aborted due to complication errors.
引用use vars后執(zhí)行結(jié)果:
use strict ;
use vars qw($str) ;
$str = "hello world!\n" ;
print $str ;
Output :
hello world!
相關(guān)文章
- fdupe 是一個很小的 Perl 腳本,用來檢索指定目錄并找出其中重復的文件,該腳本是通過文件內(nèi)容來識別是否重復文件,而非文件名。fdupe 無需其他 Perl 腳本支持,運行速度非???/div> 2013-03-03
在Perl中使用Getopt::Long模塊來接收用戶命令行參數(shù)
我們在linux常常用到一個程序需要加入?yún)?shù),現(xiàn)在了解一下perl中的有關(guān)控制參數(shù)的函數(shù).getopt.在linux有的參數(shù)有二種形式.一種是–help,另一種是-h.也就是-和–的分別.–表示完整參數(shù).-表示簡化參數(shù)2013-03-03perl寫的一個隨機編故事的程序(rand隨機函數(shù))
用perl寫的一個隨機編故事的程序,用到了rand隨機函數(shù),注釋也很詳細,需要的朋友可以參考下2013-03-03最新評論