Time of Update: 2018-12-08
轉移自自己原來在YourBlog上的Blog,寫於2004-3-11 13:05:48看了Jackey的“Windows下BugZilla安裝實錄”,按照文中的方法安裝成功,不過Jackey在實錄(二)中對於Perl模組的安裝好像不是很妥當。 看實錄(二)中模組的安裝是到CPAN網站上去下載,還需要nmake等編譯器,感覺還是比較複雜。 在Windows下安裝ActivePerl後Perl模組專門有Windows版的,這些Windows版的模組可以用ppm直接安裝的,在這裡可以下載。
Time of Update: 2018-12-08
複製代碼 代碼如下:#!/bin/perluse strict; use warnings; #定義變數 my $count; my $input; my $number; my $sentence; my $story; #定義四個數組 #定義了人物數組 my @nouns= ( 'Dad', 'TV', 'Mom', 'Groucho', 'Rebecca', 'Harpo', 'Robin Hood',
Time of Update: 2018-12-08
預設狀態下,很顯然都是用\n來區分行,\n也被我們稱作為分行符號。 當讀取序列時,按行來讀取時,就是以分行符號為標準。 讀取的strawberry1.gb的檔案內容如下: LOCUS JX118024 460 bp DNA linear PLN 25-SEP-2012 DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1) gene, partial cds; plastid. /
Time of Update: 2018-12-08
一開始打算用perldoc看Apache2::Request模組,結果在運行時出現如下錯誤:複製代碼 代碼如下:Error in tempfile() using /tmp/XXXXXXXXXX:parent directory (./) isnot writable at /usr/lib/perl5/5.8.8/Pod/Perldoc.pm line
Time of Update: 2018-12-08
之前總不重視自己的部落格,上回一丟才心疼,現在重視起來,決定定期備份sql。寫個小指令碼如下:複製代碼 代碼如下:#!/usr/bin/perluse warnings;use strict;use MySQL::Backup;use Mail::Sender;open my $tmp_sql, '>', "backup.sql";my $mb = new MySQL::Backup('dbname', 'localhost', 'dbuser', 'dbpasswd',
Time of Update: 2018-12-08
一、進程處理函數1、進程啟動函數函數名 eval 調用文法 eval(string) 解說 將string看作Perl語句執行。正確執行後,系統變數$@為空白串,如果有錯誤,$@中為錯誤資訊。 例子 $print = "print (\"hello,world\\n\");";eval ($print); 結果輸出 hello, world 函數名 system 調用文法 system(list) 解說
Time of Update: 2018-12-08
1、單行(大檔案處理):複製代碼 代碼如下:my $oneline = <$FL> 或while($line=<H>){ }2、讀取全部(小檔案處理): 複製代碼 代碼如下:open (my $in, "path ") or die "open error: $! "; my @lines = <$in> ;3、讀3行(大檔案及特殊處理需要): 複製代碼 代碼如下:open (my $in, "path ") or die "open error: $! ";
Time of Update: 2018-12-08
一、數組應用複製代碼 代碼如下:#!/usr/bin env perl@zeng = `top -b -n 1`;foreach (@zeng) {print "$_\n";}二、say的用法:自動換行複製代碼 代碼如下:#!/user/bin env perluse 5.010; #表示使用perl 5.10的版本。say "Hello World!";my @fred = above_average(1..10);print "\@fred is @fred\n";print
Time of Update: 2018-12-08
在networking方面,最基礎的是BSD socket編程,但往往perl入門時在這個方面,最頭疼的無疑是如何開始,如何Step by step。最好的藥方就是Example,一段完整的可以運行(working)的代碼,通過實踐來感受遠比看枯燥的manual來得深刻。
Time of Update: 2018-12-08
首先來看看 POSIX 風格Regex的兩個主要函數: ereg 函數:(Regex匹配) 格式:int ereg ( string pattern, string string [, array ®s] ) 注意:使用 Perl 相容Regex文法的 preg_match() 函數通常是比 ereg() 更快的替代方案。(一般的話還是使用 preg_match() ,比較好勒~~) 以區分大小寫方式在 string 中尋找與給定的Regex pattern
Time of Update: 2018-12-08
1,定界符 =~ m/there/; =~ s/there/here/; 還有類型的定界符: =~ /there/ =~ m#there#; =~ s#there#here#; =~ m(there); =~ s(there)(here); =~ m{there}; =~ s{there}{here}; =~ m[there]; =~ s[there][here]; =~ m,there,; =~ s,there,here,; =~ m.there.; =~ s.there.here.; =~
Time of Update: 2018-12-08
一、定義 子程式即執行一個特殊任務的一段分離的代碼,它可以使減少重複代碼且使程式易讀。PERL中,子程式可以出現在程式的任何地方。定義方法為: sub subroutine{ statements; } 二、調用 調用方法如下: 1、用&調用 &subname; ... sub subname{ ... } 2、先定義後調用 ,可以省略&符號 sub subname{ ... } ...
Time of Update: 2018-12-08
一、條件判斷 if ( <expression>) { <statement_block_1> } elsif ( <expression> ) { <statement_block_2> } ... else{ <statement_block_3> } 二、迴圈: 1、while迴圈 while ( <expression> ) {
Time of Update: 2018-12-08
Perl指令碼batchReplace.pl可以用來批量替換檔案中的文字/代碼。可在指定目錄中尋找指定類型的檔案,並遞迴檢查子目錄;在輸出檔案時複製輸入檔案的目錄結構。 [附件]Win32應用程式batchReplace.exe是由Perl指令碼編譯產生的可執行程式,不需安裝Perl運行環境即可執行。 在命令列中使用 batchReplace.exe[ -i 輸入檔案路徑(或包含檔案的目錄)][ -o 輸出檔案位置(檔案或目錄)][ -c 批量輸入檔案的副檔名,以“.”開始,多個副檔名之間以“|
Time of Update: 2018-12-07
安裝你自己的perl modules。當沒有root許可權的時候,需要安裝perl modules到自己的home目錄下。來自:http://servers.digitaldaze.com/extensions/perl/modules.htmlInstalling Perl5 Modules LocallyNormally, the Perl5 module installation procedure includes commands something like these:%
Time of Update: 2018-12-07
來自:http://www.perlfect.com/articles/sorting.shtml perl 比較操作符列表: NumbersStrings<lt>gt<=le>=ge==eq<=>cmp!=ne <=> 和cmp的詳細解釋: Relation of $a and $bValue Returned by $a <=>$a greater than $b1$a equal to $b0$a less than
Time of Update: 2018-12-07
原文地址:http://blogread.cn/it/article/743?f=wb 用Perl寫了一些監控指令碼,放在crontab中調度執行。有時候會發現一個指令碼已耗用時間過長,會同時跑起多個執行個體,因此有必要為指令碼加上控制,只運行一個執行個體。最簡單自然的想法,在指令碼中檢查並建立一個空的lock檔案,指令碼結束時再刪除。通過判斷檔案是否存在的方式來判斷指令碼是否已經運行。不過這樣做有個bug,如果指令碼運行過程中異常終止,lock檔案沒有正常刪除,就會導致指令碼無法再運行。空的l
Time of Update: 2018-12-07
前面一節介紹了Perl中的基礎資料型別 (Elementary Data Type)及其使用方式,本節介紹一下分支迴圈控制及IO。 Perl中的分支迴圈在文法上和C家庭語言的文法很相似,關鍵字包括: If / else, for ,while 。 前面已經講過,Perl中代碼塊用大括弧{}圍起來,運算式以分號結尾,這些都和C相似, 但在Perl中,使用if for
Time of Update: 2018-12-07
什麼是Perl? perl是一門免費及開源的指令碼語言,由Larry Wall所創造,這門語言以實用,快速開發為主要目標, 與當前流行的物件導向,結構化編程有些格格不入。 但是這並不妨礙perl被廣泛流傳和使用,世界範圍內圍繞Perl建立起了非常活躍的社區, 很多人在其中不斷協助完善文檔,建立範例程式碼,提供一些第三庫等等。 具體可以瀏覽以下兩個網頁:www.cpan.org , www.perl.com.
Time of Update: 2018-12-07
Perl中處理時間的函數有如下幾種: 1、time函數:返回從1970年1月1日起累計的秒數 使用:my $t=time(); 2、 localtime函數:擷取本地時區時間 使用:my $t=localtime(time()); 3、gmtime函數: 擷取格林威治時間 使用:my $t=gmtime(time());