190 likes | 333 Views
Perl 6 - an Introduction. Presented by jonasbn Yet Another Perl Monger <jonasbn@io.dk>. Larry Wall. Damian Conway. From Apocalypse to Exegesis. Larry Wall. The inventor of Perl Processes RFCs Writes Apocalypses (1-5). Damian Conway. Inventor of many fantastic modules
E N D
Perl 6 - an Introduction Presented by jonasbn Yet Another Perl Monger <jonasbn@io.dk>
Larry Wall Damian Conway From Apocalypse to Exegesis
Larry Wall • The inventor of Perl • Processes RFCs • Writes Apocalypses (1-5)
Damian Conway • Inventor of many fantastic modules • Writes Exegesises (3-5)
This Talk • This talk will evolve around the content of Apocalypse 3 VERY much the corresponding Exegesis 3 • Will mostly be about syntax (variables, operators, functions, arrays and hashes) • So lets start with something we know…
Hello World of Perl6! #!/usr/bin/perl use warnings; use strict; print "Hello World of Perl6!\n";
Variables • $_ is a lexical variable • $?, $!, $@ and $^E consolidated into $! • @ARGV changes name to @ARGS
String Concatenation Operator • String concatenation changes from .= to _= $fullname = getFirstname _ getLastname;
Binary Default Operator // my $debug //= $param{‘debug’} // 0;
Arrays • The ($#) operator referring to the length of an array disappears, or is changed to @array.end or the Perl 6 semi-infinite list @array[1..] • Maybe @array[1..INF]
Arrays #!/usr/bin/perl use Perl6::Variables; my @array = ('Egon', ’Benny', ’Keld'); for (my $i = 0; $i < (scalar @array); $i++) { print "@array[$i]\n"; }
Hashes #!/usr/bin/perl use Perl6::Variables; my %hash = ( 'Fy' => 'Bi', 'Keld' => 'Dirk', 'Pallesen' => 'Pilmark' ); foreach my $key (keys %hash) { print "$key og %hash{$key}\n"; }
Functions • Named parameters • $f is a scalar • $v is an optional scalar • *@array is a list (* == list context asterisk), where @array would be an array or array reference sub func ($f ; $v, *@array) {
Named Parameters Again • Perl 5 (=>) is just a comma • Perl 6 (=>) is an constructor $d = setName(first => ‘Jonas’, last => ‘N.’); sub setName( $pair_ref1, $pair_ref2) { …
Open Function • Open no longer takes a BAREWORD
Enough Talk • We have now briefly touched Perl 6 • Perl 6 is still under development • Perl 6 has a long way to go • Many Apocalyptic writings and Exegesises will follow
Getting Started on Perl 6 • Download Bundle::Perl6 from CPAN • Read the Exegesises
References • ‘And Now for something completely similar’, Article by Damian Conway. SysAdmin, March 2002 Vol. 11, Number 3. • Apocalypse 1, Larry Wall • Exegesis 3, Damian Conway