2011年5月15日星期日

Re: [PerlChina] Perl 5.14.0 正式发布


woosley@woosley:~/perl5/perlbrew$perl --version

This is perl 5, version 14, subversion 0 (v5.14.0) built for i686-linux

Copyright 1987-2011, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


我最喜欢操作hash/array引用的新特性

$perl -E '$a = [];  push $a, qw/hello Perl-5.14.0/; say "@$a"'
hello Perl-5.14.0


在 2011年5月15日 下午2:57,Robin Lee <robinlee.sysu@gmail.com>写道:
详见: http://search.cpan.org/~jesse/perl-5.14.0/pod/perldelta.pod

基本上是标题党,因为目前还没用上。看完 delta 后列两个个人比较喜欢的新特性:

1. 新的正则替换选项 /r
一直来正则替换(s///)都是直接作用于操作变量。要想原操作变量不变,只想要把替换后的结果保存要另一个变量,要这样写:
my $old = "cat";
my $new = $old;
$new =~ s/cat/dog/;

有了 /r 选项后,就可以这样写
my $old = "cat";
my $new = $old =~ s/cat/dog/r;

也即是正则替换不修改操作变量,并且把替换后的结果作为返回值。

2. package NAMCESPACE [VERSION] BLOCK
package Foo { ... } 相当于 { package Foo; ... }
package Foo 1.2 { ... } 相当于  { package Foo; $VERSION = 1.2; ... }

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Woosley.Xu



--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

没有评论: