Time of Update: 2014-07-24
標籤:使用 os 資料 re c ar perl中DBI模組為mysql資料庫相關操作的介面,首先需要在環境中安裝DBI模組。perl處理資料庫操作的大致步驟如下:#聲明使用DBI模組use DBI;#設定資料庫連接參數,指定串連資料庫名,資料庫所在伺服器ip地址,串連使用者名稱,密碼# db_
Time of Update: 2015-01-06
標籤:perlThe way I am using is PAR Packer. 1. Downloadmodule PAR Packer: http://search.cpan.org/~rschupp/PAR-Packer-1.024/lib/PAR/Packer.pm2. InstallPAR Packer:2.1 Unzipthe
Time of Update: 2015-01-03
標籤:perl socket selectserver程式接受用戶端資訊,並發送回應#!/usr/bin/perl -w# socket_server.pluse strict;use IO::Socket;use IO::Select;# hash to install IP Portmy ($ser_addr, $ser_port)=("127.0.0.1", "12345");our($buffer, $len);my $socket = IO::Socket::INET->new(
Time of Update: 2014-12-28
標籤:#! /usr/bin/perluse strict;use utf8;binmode(STDIN,":encoding(utf8)");binmode(STDERR,":encoding(utf8)");binmode(STDOUT,":encoding(utf8)");&extend("/home/hqh/案頭/2",1,",","/home/hqh/案頭/1",1,",","/home/hqh/案頭/result");sub extend{
Time of Update: 2014-12-09
標籤:perl 正則 shell A. 原文替換perl -p -i.bak -e "s/源串/目標串/g" <檔案名稱>原文會備份為.bak尾碼的檔案B. 正則分組提取echo "tom and dic" | perl -n -e ‘ @w = /(tom).*(dic)/; print "$w[0] & $w[1]"‘列印 “tom & dic”註:-p
Time of Update: 2014-12-04
標籤:替換字串 perl my %TEMP=(‘${TMP}‘=>‘SSS‘, ‘${PROJECT_ROOT}‘=>‘aaaaaaaa‘, ‘${MCB_PATH}‘=&g
Time of Update: 2014-11-30
標籤:io for 檔案 on ef res 學習 br 字串 語句:if/unlesswhile/foreach/do..while/for1.運算式真價值總結任何錶達式都有真假值:邏輯、字串
Time of Update: 2014-09-19
標籤:blog 使用 ar div sp log c ef c++ perl不像C/C++有各種變數類型。perl中的變數類型通過上下文來確定,到底是字串還是整形變數。例如: my
Time of Update: 2014-08-21
標籤:perl1、字串內用index搜尋$where = index($words,$word);##從words裡找到首次出現word的位置,下標從0開始,尋找失敗則返回-1;指定開始搜尋的地方:$where = index($words,$word,10);##從10開始往後尋找,包含10搜尋子串最後出現的位置:限定返回的最大位置:$where =
Time of Update: 2014-08-07
標籤:style 使用 檔案 for amp 學習 程式 不同的 1、在Perl中,子程式名與變數名屬於不同的命名空間,可以使用同一個名字分別命名子程式和變數,但不建議這樣使用。2、子程式的定義是全域的,同名的子程式後邊的會覆蓋
Time of Update: 2014-08-06
標籤:http 檔案 資料 ar div html htm .net \w 匹配一個字母、數字或底線,相當於[a-zA-Z_0-9]\s 匹配一個Null 字元\d 匹配一個數字\b
Time of Update: 2018-12-08
複製代碼 代碼如下:#!/usr/bin/perl#use strict;open(FILE1,"C:/Perl/BX/BX-Users.csv");open(FILE2,"C:/Perl/BX/BX-Books.csv");open(FILE3,"C:/Perl/BX/BX-Book-Ratings.csv");open(result1,">C:/Perl/BX/BX-Users.txt");my %table;my $record1;my $count1;#my
Time of Update: 2018-12-08
複製代碼 代碼如下:#!/usr/bin/perl -wuse strict;use warnings;use FileHandle;my %fh;my @array = (1..10);for(1..5){ open $fh{$_},">$_.txt" or die;}for(1..5){ #print $fh{$_} "$_\n"; 此處錯誤 $fh{$_}->print( "$_\n" ); #為FileHandle裡的函數
Time of Update: 2018-12-08
1)預設的INC如下:複製代碼 代碼如下: @INC: C:/Perl/site/lib C:/Perl/lib2)設定環境變數PERL5LIB來增加到INC,例如: set perl5lib=c:\perllibs 在設定perl5lib後如下,複製代碼 代碼如下:%ENV: PERL5LIB="c:\perllibs" @INC: c:\perllibs C:/Perl/site/lib C:/Perl/lib3)在perl程式中修改INC,
Time of Update: 2018-12-08
操作csv這樣的表格在perl處理檔案中是經常要碰到的。這樣的表類似二維數組,因此實際上的操作時對二維數組的操作了。對這樣的行列表格,我們常常需要按照某列,或者先按照某列,再按另一列進行排序,這裡貼上perl的實現,以便下次使用尋找。看下面這段代碼。複製代碼 代碼如下:#!/usr/bin/perlmy @line;while(<>){chomp;push @line, [ split ];}foreach ( sort { $a->[0] <=> $b->[
Time of Update: 2018-12-08
讀檔案:複製代碼 代碼如下:#!perlopen filetxt,"/path/a.txt"; # filetxt為檔案控制代碼,用於和檔案a.txt建立連結。檔案控制代碼可任意取名,但不要和Perl內建的幾個檔案控制代碼重名。print <filetxt>; # 此處print函數用於顯示檔案a.txt的內容。<>為取行操作符,<檔案控制代碼>用於讀取所連結檔案的內容。close filetxt;
Time of Update: 2018-12-08
刪除檔案使用unlinke函數,比如unlink $file, unlink $file1, $file2, $file3開啟檔案使用三參數的形式開啟檔案,這樣非常便於區分模式和檔案名稱,perl 5.6之後的版本都支援這種方式。複製代碼 代碼如下:#Open the 'txt' file for readingopen FH, '<', "$file_name.txt" or die "Error:$!\n";#Open the 'txt' file for writing.
Time of Update: 2018-12-08
複製代碼 代碼如下:#!/usr/bin/perl## 用grep map 擷取兩個列表的交集並集、補集#use strict;my @a=("a","b","c","d","e");my @b=("b","g","f","e");print "列表a資料: @a \n";print "列表b資料: @b \n";my %a = map{$_ => 1} @a;my %b = map{$_ => 1} @b;my @c = map{$_ => 1} @a; #
Time of Update: 2018-12-08
Perl 的相比起來還是少.看視頻,在入門時還是相當方便的,就象電影來看就好了。我基本 Superor 老師每出一集我都看了。希望大家也認真看看。記的,學習時要多寫,只能看明白,只有 5% 是你的,練習都做一做,就有 30% 是你的啦。其它的如果能根據教程,自己寫出自己要的程式,才 80% 是你的.再次感謝 Superor 老師.注意下面的內容,如果加 .zip 可以直接下載的。例如:http://www.boobooke.com/v/bbk2869.zip第1集:第一章
Time of Update: 2013-12-27
大家有時候執行一個指令碼,因為指令碼中有些程式的假死和逾時,影響了我們對下一步的判斷。隨意我們有必要設定對函數和進程的逾時設定,讓他在一段時間沒有反應後,return一個狀態。 在命令參數裡ssh -o ServerAliveInterval=60