複製代碼 代碼如下:#!/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',
1、讀取某檔案,如果該檔案不存在,則報錯,並提示出錯原因open (DB, "/home/ellie/myfile") or die "Can't open file: $!\n"; 運行後提示:Can't open file: No such file or director 2、讀寫檔案的方法:open(FH, "<filename"); # Opens "filename" for reading.讀 # The <
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
1. List and Array. 本書中所講的List是一種資料結構,Array是Perl中用來存放List的資料類型。大部分情況下,這兩個單詞可以互換,意思是一樣的。和C不一樣 的是,Perl的Array不用定義元素的類型,也就是說,Perl中的Array中的每個元素可以是Number,也可以是String,元素的類型沒 必要都一樣。和C相同的就是,對Array的訪問都是通過下標進行的,第一個元素的數組下標是0。 2. Perl中的Array用起來和C中的沒什麼區別: $fred[0]
http://xerces.apache.org/ The Apache Xerces Project currently consists of the following sub-projects, each focused on the development of XML parsers and related components in various languages:Apache Xerces C++ - A processor for parsing, validating,
fcntl FILEHANDLE,FUNCTION,SCALARImplements the fcntl(2) function. You'll probably have to say use Fcntl;first to get the correct constant definitions. Argument processing and value returned work just like ioctlbelow. For example:use