Home Index

1  Programming

2  Perl

+ Binary File

+ Class

+ Computation

+ Constants

+ Cpan

+ Debug

+ Domain

+ Files

+ Formatting

+ Generics

+ Inline C

+ JSON

+ Lexical

+ Moose

+ People

+ PerlCritic

+ Reference

+ Regex

+ Tail

+ Unit Test

+ perl-support

+ perlbrew

The Perl Programming Language

Perl is a highly capable, feature-rich programming language with over 20 years of development. Perl 5 runs on over 100 platforms from portables to mainframes. Perl is suitable for both rapid prototyping and large scale development projects.

New Fetures in Perl 5.10

#---------------------- Smart Match -------------------#
use feature '~~';
if($url ~~ @array)     { say "$x exists" }
if($url ~~ /google/)   { say "google is in the string" }
if(@array ~~ /google/) { say "google is in the array" }
if($key ~~ %hash)      { say "$key exists in the hash" }
if($subref ~~ %args)   { say 'sub($args) true' }

#----------------------- Defined Or ------------------#
$c = $a // $b is handler
    Same As 
$c=defined($a) ? $a : $b;

#--------------------- State Variable ----------------#
use feature 'state';
sub incrementor {
    state $i = 0;
    return $i++;
}

#-------------------- Switch Statement ---------------#
use feature 'switch';
foreach(@array) {
    when(/google/) { $google++ }
    when(/yahoo/)  { $yahoo++  }
    when(/bing/)   { $bing++   }
    say "$_ non of the above ...";
}


Reference: http://www.slideshare.net/acme/whats-new-in-perl-510

Copyright © 1997-2012 Kevin T. Duraj, All rights reserved
Agoura Hills, California -  Saturday, 19 May 2012