LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 958|回复: 1

perl问题

[复制链接]
发表于 2005-9-23 22:49:18 | 显示全部楼层 |阅读模式
1 : #!/usr/local/bin/perl
2 :
3 : while ($inputline = ) {
4 : while ($inputline =~ /b[A-Z]S+/g) {
5 : $word = $&;
6 : $word =~ s/[;.,:-]$//; # remove punctuation
7 : $wordlist{$word} += 1;
8 : }
9 : }
10: print ("Capitalized words and number of occurrences:n");
11: foreach $capword (keys(%wordlist)) {
12: print ("$capword: $wordlist{$capword}n");
13: }

第5句话是什么意思?wordlist如何出来的?
发表于 2005-10-8 09:37:27 | 显示全部楼层
$&是一个只读变量,用来存储匹配正则表达式的那个substring。

%wordlist是一个hash。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表