Perl (5|6)?
Perl (5|6)?
Mostly about Perl 5
Then and Now
| 2002 | 2012 |
Perl 5 | 5.8 | 5.16 |
Encoding | Legacy | UTF-8 |
Encoding
use v5.16;
use utf8;
use encoding 'utf8';
sub ふば {
["ふぃず"]->[ $_ % 3 ]
. ["ばず"]->[ $_ % 5 ]
|| $_
}
say ふば($_) for 1..30;
Then and Now
| 2002 | 2012 |
Perl 5 | 5.8 | 5.16 |
Encoding | Legacy | UTF-8 |
use 5.X | checks version | change version |
use 5.X
my $string = "Hello, world!";
print $str;
use 5.X
use strict;
use warnings;
my $string = "Hello, world!";
print $str;
use 5.X
use v5.16;
my $string = "Hello, world!";
print $str;
use 5.X
use v5.8;
my $string = "Hello, world!";
print $str;
Then and Now
| 2002 | 2012 |
Perl 5 | 5.8 | 5.16 |
Encoding | Legacy | UTF-8 |
use 5.X | checks version | change version |
use feature | | say, //, __SUB__… |
use feature
{
use feature 'say';
say ["Fizz"]->[ $_ % 3 ]
. ["Buzz"]->[ $_ % 5 ]
|| $_
for 1..30;
}
use feature
{
use feature 'say';
say ["Fizz"]->[ $_ % 3 ]
. ["Buzz"]->[ $_ % 5 ]
|| $_
for 1..30;
}
say "Hello";
__SUB__
use feature qw/say current_sub/;
sub {
my $n = shift;
say ["Fizz"]->[ $n % 3 ]
. ["Buzz"]->[ $n % 5 ]
|| $n;
__SUB__->( ++$n ) if $n < 30;
}->(1);
__SUB__
use feature qw/say/;
sub {
my $n = shift;
say ["Fizz"]->[ $n % 3 ]
. ["Buzz"]->[ $n % 5 ]
|| $n;
__SUB__->( ++$n ) if $n < 30;
}->(1);
Simply Put
- We have added features…
- without breaking legacy codes.
Simply Put
- We have added features…
- without breaking legacy codes.
- Your 2002 codes runs unchanged in 2012.
Simply Put
- We have added features…
- without breaking legacy codes.
- Your 2002 codes run unchanged in 2012.
- Python 2 vs 3?
- Ruby 1.8 vs 1.9?
Simply Put
- We have added features…
- without breaking legacy codes.
- Your 2002 codes run unchanged in 2012.
- Python 2 vs 3?
- Ruby 1.8 vs 1.9?
- Will run in 2022 and years to come.
One more thing
Language Update Decade
- Perl
- PHP
- Python
- Ruby
- JavaScript?
The most important LL is missing!
| 2002 | 2012 |
Server | Perl, PHP, Python, Ruby … | Perl, PHP, Python, Ruby, JavaScript … |
The most important LL is missing!
| 2002 | 2012 |
Server | Perl, PHP, Python, Ruby … | Perl, PHP, Python, Ruby, JavaScript … |
Client | | JavaScript |
JavaScript the only language
- that runs on both sides
- that runs without installing
- anything else is secondary
JavaScript + Something
| 2002 | 2012 |
Web | Static | Dynamic |
HTML | 4.01 | 5 = HTML+CSS+JS |
Server emits | HTML | JSON |
Web programming | Server Side | Both Sides |
Language | LL of your choice | JS + LL of your choice |
JavaScript ∽ Perl
- Both are lightweight languages
- no compilation
- objects
- closures
- …
- Method names in (String|Array).prototype
- "use strict"
Perl != JavaScript
- Preinstalled in almost all servers
- CPAN
- Shell-friendly
- cpan(plus|m)?
- perlbrew
- one-liners
Use Perl
The following shall remain true for years to come.
- A language for getting your job done.
- Easy thing should be easier, without making hard things harder
- There's more than one way to do it.
- more than one language to do it.
御礼なう
sub questions {
answer shift and __SUB__->(@_);
}