1. [10]寫乙個程式,輸出所有提到fred 的行(不要輸出其它行)。如果輸入字串fred, fredrick, alfred,能匹配上嗎?準
備乙個小的文字檔案,其中包含如:「fred lintsotne」以及類似的資訊。使用這個文字檔案作為此程式的輸入,以及本節
下面練習的輸入。
2. [6]修改上面的程式,允許匹配fred。現在它能匹配,fred, fredrick, alfred 嗎?(將這些名字加入輸入檔案中)
3. [6]寫乙個程式,輸出出現句號(.)的行,忽略其它行。使用前面練習中的檔案進行練習:它能找到mr. slate 嗎?
4. [8]寫乙個程式,輸出有乙個字母大寫,而非所有字母都大寫的行。它能匹配fred,而不匹配fred 和fred 嗎?
5. [8]額外的練習:寫乙個程式,它能輸出所有同時提到wilma 和fred 的行。
1~3、
#!/usr/bin/perl -w
use strict;
while(<>)}4、
if(/([a-z])+/){
5、if(/wilma.*fred|fred.*wilma/){
《Perl語言入門》第四版習題(12)
1 usr bin perl w use strict if argv else foreach 2 usr bin perl w use strict if argv else foreach 3 usr bin perl w use strict print which directory?de...
《Perl語言入門》第四版習題(13)
1.10 寫乙個程式,讀入一串數字,將它們按照數字排序,將結果按右對齊的列列印出來。使用下面的資料進行檢測 17 000 04 1.50 3.14159 10 1.5 4 2001 90210 666 2.15 寫乙個程式,將下例hash 資料根據姓 last name 按照大小寫無關的字母順序進行...
C primer 第四版部分習題的解答
1.16 include include using namespace std int main 1.17 include using namespace std int main system pause return amount 這裡有乙個需要注意的地方是檔案結束符的使用。即cin在什麼時候...