清源绿里

Perl字符串处理

最近因为工作需要用 Perl 脚本语言编写连接程序以实现几个专业程序间的外部耦合。就像三年前编写核电厂指标系统的 PHP语言 一样,连业余都算不上的我总得这些时候现学现卖,一边在网上找例子,一边写代码。留此系列文章仅为自己今后搜寻方便,假若也能为同道中人提供一些帮助,那最好不过。

1,字符串替换

  1. # This is a string substituion sample.
  2. # "\" should be used before "$"
  3.  
  4. $array = "This is Tsian's \$blog.\n";
  5. print $array;
  6. $blog = "Para Sempre";
  7. $array =~ s/\$blog/$blog/;
  8. print $array;
  9.  
  10. # results:
  11. # This is Tsian's $blog.
  12. # This is Para Sempre.

Popularity: 3% [?]

Leave a Comment