《Perl語言入門》第四版習題(12)

2021-05-09 12:03:32 字數 855 閱讀 6910

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?(default is you home directory): ";

chomp(my $dir=);

if ($dir=~/^/s*$/)else

opendir dh,"." or die "can't opendir dh: $!";

foreach (sort readdir dh)

4、#!/usr/bin/perl -w

use strict;

for (@argv)

5、#!/usr/bin/perl -w

use strict;

rename $argv[0],$argv[1];

6、#!/usr/bin/perl -w

use strict;

link $argv[0],$argv[1] or warn "can't link";

7、#!/usr/bin/perl -w

use strict;

symlink $argv[0],$argv[1] or warn "can't symlink";

8、#!/usr/bin/perl -w

use strict;

foreach(<.* *>)

《Perl語言入門》第四版習題(7)

1.10 寫乙個程式,輸出所有提到fred 的行 不要輸出其它行 如果輸入字串fred,fredrick,alfred,能匹配上嗎?準 備乙個小的文字檔案,其中包含如 fred lintsotne 以及類似的資訊。使用這個文字檔案作為此程式的輸入,以及本節 下面練習的輸入。2.6 修改上面的程式,允...

《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在什麼時候...