Perl 5.14 released
Perl 5.14 released
Written by Nikos Vaggalis   
Thursday, 19 May 2011

Perl 5.14, this year's stable release of the Perl 5 language, has been released with several welcome feature, the most important being to its Unicode features.

Perl 5.14, this year's stable release of the Perl 5 language, is the first in the planned series of annual time-based releases announced last year. From the Perl developer's point of view it has several important features:

Unicode

Perl 5.14 has Unicode 6.0 support and other unicode-related improvements, the most the important being the 'unicode_strings' feature which instructs the compiler to use Unicode semantics rather than the traditional Perl's native Unicode model therefore alleviating issues associated with it (see "The UTF8 flag" in Unicode issues in Perl.)

Regular Expressions

New regular expression modifiers let you explicitly use ASCII, Unicode, or locale semantics for character classes regardless of the strings internal encoding. This means that for example use locale 'greek' on a Unicode string, the regular expression will operate only on Greek characters

Also a handy a non-destructive version of the substitution operator is introduced with the /r flag. This means that the target string is not modified but instead the processed string is returned hence you can replace code like the following :

use 5.010000;
my $name="a1b2c3d";
my $temp;
$temp = $name =~ s/\d/x/g;
say $temp;
#prints: 3 which is
#the number of substituted characters
say $name;
prints: axbxcxd

or this which keeps the target string ($name) intact while storing the resulted string in $temp:

use 5.010000;
my $name="a1b2c3d";
my $temp;
( $temp = $name ) =~ s/\d/x/g;
say $temp;
#prints: axbxcxd
say $name;
#prints: a1b2c3d

with code using the new /r modifier:

my $name="a1b2c3d";
$temp=$name =~ s/\d/x/gr;
say $temp;
#prints: axbxcxd
say $name;
#prints: a1b2c3d

Syntactical Enhancements

Array and hash container functions accept references; for example, the array operators (push, pop, shift, unshift) were operating on named arrays but now also operate on array references as well

(For a deeper explanation see "Perl strongly typed?" in Strong typing)

The following example won't compile on pre 5.14 installations :

my @a=(1,2,3);
my @b=(4,5,6);
my $array_ref=\@a;
push $array_ref,@b;
print @a;
#Type of arg 1 to push must be array (not 
#scalar dereference) at c:\1.pl line 5,
#near "@b;"\
#Execution of c:\1.pl aborted due to
#compilation errors.

while in 5.14 it will produce the following :

#prints: 123456

Exception Handling

Better exception handling, not in the sense of SEH with try catch clauses but fixed some issues making it more reliable.

perl

Other enhancements include specifying any character with its ordinal value in octal and that srand() now returns the seed.

Some features were deprecated as part of the language clean up. For all the details check the Perl 5.14 delta.

The massive task of updating all Activestate module packages (PPM) 5.14 has already begun and you can check the PPM index pages for the latest updates.

 

If you would like to be informed about new articles on I Programmer you can either follow us on Twitter or Facebook or you can subscribe to our weekly newsletter.

Banner


Microsoft Offers More Revenue To Developers
10/05/2018

At Build 2018 Microsoft announced an incentive to encourage developers to create apps for Windows 10. A new fee structure will enable devs to keep 95 percent of revenue earned from certain apps.  [ ... ]



NetBeans 9 RC1 Ready to Go
23/05/2018

NetBeans seems to have survived its transition from Oracle to Apache, but it is still difficult to say how well. The long-awaited version 9 is ready for serious work and you can download the release c [ ... ]


More News

<ASIN:143022715X>

<ASIN:0321496949>

<ASIN:159059391X>

<ASIN:0596520107>

<ASIN:0596000278>

Last Updated ( Thursday, 19 May 2011 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.