$& $` $' 格式匹配

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/local/bin/perl
while ($inputline =(<>) ) {
  while ($inputline = ~/\b[A-Z]\S+/g){
    $word = $&;
    $word =~ =~ s/[;.,:-]$//;
    $wordlist{$word} +=1;
  }
  print ("Capitalized words and number of occurrences:\n");
  foreach $capword (keys(%wordlist)) {
    print ("$capword: $wordlist{$capword}\n");} 
  }
perl 一些内置常量
$& :与格式匹配的字符串
$` : 格式匹配信息前的字符串 
$’: 格式匹配信息后的字符串

例如:
$inputline =" 12 asdf Capliz qqr 124";
$inputline =~ /\b[A-Z]\S+/;
$`:"12 asdf "
$&:"Capliz"
$':" qqr 124"