孤獨者 - 心在黑暗裡旅行 ...... ...
至尊會員
遊蕩的過客 - 枉入紅塵若許年 .. ...
[ols3@p4 sample]$ perl -e 'print "Hello Perl !!\n";' Hello Perl !!
perl -pi.bak -e 's/\r//g;' index.html
perl -v 結果: This is perl, v5.8.0 built for i386-linux-thread-multi Copyright 1987-2002, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at 訪客無法瀏覽此圖片或連結,請先 註冊 或 登入會員 。, the Perl Home Page.
[ols3@p4 sample]$ perl -c hello.pl hello.pl syntax OK
[ols3@p4 perl_intro]$ perl -h Usage: perl [switches] [--] [programfile] [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -C enable native wide character system interfaces -c check syntax only (runs BEGIN and CHECK blocks) -d[:debugger] run program under debugger -D[number/list] set debugging flags (argument is a bit mask or alphabets) -e 'command' one line of program (several -e's allowed, omit programfile) -F/pattern/ split() pattern for -a switch (//'s are optional) -i[extension] edit <> files in place (makes backup if extension supplied) -Idirectory specify @INC/#include directory (several -I's allowed) -l[octal] enable line ending processing, specifies line terminator -[mM][-]module execute `use/no module...' before executing program -n assume 'while (<>) { ... }' loop around program -p assume loop like -n but print line also, like sed -P run program through C preprocessor before compilation -s enable rudimentary parsing for switches after programfile -S look for programfile using PATH environment variable -T enable tainting checks -t enable tainting warnings -u dump core after parsing program -U allow unsafe operations -v print version, subversion (includes VERY IMPORTANT perl info) -V[:variable] print configuration summary (or a single Config.pm variable) -w enable many useful warnings (RECOMMENDED) -W enable all warnings -X disable all warnings -x[directory] strip off text before #!perl line and perhaps cd to director
查看詳細資料
TOP
整數: 1 0 566 -80 37999 浮點數: 3.141573259 4.000 1.96e24 -4.5E-18 八進位數:(以 0 開頭) 0523 (相當於十進位數:339) 十六進位數:(以 0x 開頭) 0x27af (相當於十進位數:10159) 二進位數:(以 0b 開頭) 0b11010011 (相當於十進位數:211)
加 + 例:5 + 9 減 - 例:100.9 - 10.2 乘 * 例:7 * 8 除 / 例:56 / 7 求餘數 % 例:41 % 2 乘冪 ** 例:2 ** 4 (2 的 4 次方 = 16)
-> 方法呼叫、解參考 ++ 遞增, -- 遞減 ** 乘冪(次方) ! 非,~ 位元運算的 非,\ 參考 =~ 比對相符,!~ 比對不符 * 乘,/ 除, % 求餘數, x 字串倍數 + 加、- 減, . 字串連接 << 位元左移,>> 位元右移 < 小於,> 大於,<= 小於或等於,>= 大於或等於,lt 字串小於,gt 字串大於,le 字串小於或等於,ge 字串大於或等於 == 等於,!= 不等於,<=> 數值比較,eq 字串等於,ne 字串不等於,cmp 字串比較 & 位元AND | 位元OR,^ 位元 XOR && AND(且) || OR (或) .. 範圍 ? : 三元運算子,例: ($a > $b) ? $a : $b; = 指定,+=、-=,*= 等等 , 逗號運算子,=> 箭號運算子 not 邏輯的 NOT and 邏輯的 AND or 邏輯的 OR xor 邏輯的 XOR
'John and Marry' '真的好!' '12345 大家來跳舞' 'hello world\n' "中文沒問題" "hello world\n"
\n 換行符號 \r 回行符號 \t 定位 tab 符號 \f 跳頁 \b 退格 \a 鈴聲 \0 八進位數,如:\007 \x 十六進位數,如:\x16 \\ \ 這個符號 \" " 雙引號
比如: print "hello world\n"; 出現 hello world 並且游標換至下一列 而 print 'hello world\n'; 出現 hello world\n 且游標沒有換行。
比如: $hi="Hello"; print "$hi\n"; 出現 Hello 並且游標換至下一列 而 $hi="Hello"; print '$hi\n'; 出現 $hi\n 且游標沒有換行。
print '12345 大家來跳舞' . " hello world"; 結果變成: 12345 大家來跳舞 hello world
print "OK" x 4; 結果變成: OKOKOKOK
本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。