Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2018年残暑のPerl

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

 2018年残暑のPerl

Learn Language 2018 in ODC

Avatar for Kenichi Ishigaki

Kenichi Ishigaki

August 26, 2018
Tweet

More Decks by Kenichi Ishigaki

Other Decks in Technology

Transcript

  1. me • 2016年のPerl@LLoT • Perl in 2016@YAPC::Hokkaido • 2017年春のPerl@YAPC::Kansai •

    2017年夏のPerl@YAPC::Fukuoka • (2018年初夏のPerl5)@Hokkaido.pm #14 • 2018年夏のPerl5@Shibuya.pm #18 • 2018年残暑のPerl@LL2018 <- イマココ
  2. ヒアドキュメントがインデント可能に (5.26) { my ($key, $value) = qw/foo bar/; my

    $json_template = << "END"; {"$key": "$value"} END } { my ($key, $value) = qw/foo bar/; my $json_template = <<~ "END"; {"$key": "$value"} END }
  3. 異なる種類のハンドルの共有は エラーに (5.28) # 5.26まで open my $hd, '<', 'foo.txt';

    opendir $hd, 'bar/'; say <$hd>; # foo.txtの中身を出力 say readdir $hd; # barディレクトリのファイル一覧 # 5.28 Cannot open $hd as a dirhandle: it is already open as a filehandle
  4. @INCからカレントディレクトリが 除去 (5.26) • 数年越しのセキュリティフィックス • 古いCGIスクリプトなどは動かなくなるかも • まずはツールチェーンのアップデートを •

    requireなどは起点のパスを追加 • 必要なら@INCの末尾に"."を戻す #!/usr/bin/perl require "jcode.pl"; do "main.pl"; #!/usr/bin/perl require "./jcode.pl"; do "./main.pl";
  5. encodingプラグマの変更 (5.26) × use encoding 'cp932'; ◦ use encoding 'cp932',

    Filter => 1; • 日本語Windows環境で5C問題にわずらわ されずに小物スクリプトを書くときには便利 だったのですが…
  6. 正規表現中のあいまいな { の扱い (5.26) • 5.16で廃止、5.22で警告、5.26でエラーに • CPANのみならずgolangのテストなどにも影響 • autoconfで問題発覚。該当の表現のみ警告に

    $foo =~ /¥d{1,10}/; # ok $foo =~ /something{}/; # 5.26ではエラー $foo =~ /something[{]/; # ok $foo =~ /something¥{/; # ok $foo =~ /{}/; # これもok $foo =~ /$hash{bar}/; # ok $foo =~ /$hashlike{}/; # 5.26ではエラー $foo =~ /¥$foo/; # ok $foo =~ /¥${foo}/; # 5.26ではエラー $foo =~ /¥${[^¥}]*}/'; # autoconf問題
  7. 正規表現中のあいまいな { の扱い (5.28) • 一部はふたたび警告に $foo =~ /something{}/; $foo

    =~ /¥${foo}/; # 5.28から警告、5.32でエラーになる予定 $foo =~ /({1})/; $foo =~ /¥({1}¥)/; # これはOK
  8. サブルーチンシグネチャの 再修正 (5.28) • 5.20で実験的に導入 • 5.22でシグネチャとアトリビュートの並び順が変更に • 高速化も進み、シグネチャなしの場合とほぼ同等に •

    :lvalueの場合に問題が発覚したため、再度仕様変更 (lvalue: $obj->setter = "value"; のような構文) sub f :lvalue ($a, $b) { ... }; # 5.20 sub f ($a, $b) :lvalue { ... }; # 5.22~5.26 sub f :lvalue ($a, $b) { ... }; # 5.28~
  9. いろいろと議論は ありました • Perl 5 Core Hackathon (2016年~) • 廃止予定のロードマップ作成

    (5.26) • 実装予定のロードマップ? • 継続的テストの対象拡大? • 理想と現実
  10. CPAN Meta DBの統計によると… • 公式サポートバージョンは 3割程度 2018年08月25日時点で サンプル数が最大なのは 5.16.3 (15.7%)

    • CentOS 5の退役で5.8.8 が1%以下に • あくまで参考程度に http://cpanmetadb.plackperl.org/versions/?date=20180825
  11. PPR (2017) • Damian Conway氏作 • Pattern-based Perl Recognizer •

    正規表現でPerlコードをパース • 5.10で追加された(DEFINE)を活用 use PPR; # $source_codeがPerlとして正しく解析できるか確認 if ($source_code =~ m{¥A (?&PerlDocument) ¥Z $PPR::GRAMMAR}x) { ... } else { say "¥$source_codeに構文エラーがあります"; }
  12. PPR (2017) our $GRAMMAR = qr{ (?(DEFINE) (?<PerlDocument> ¥x{FEFF}?+ #

    Optional BOM marker (?&PerlStatementSequence) ) # End of rule (?<PerlStatementSequence> (?&PerlPodSequence)?+ (?: (?&PerlStatement) (?&PerlPodSequence)?+ )*+ ) # End of rule ... (こんな感じの定義が約1750行) }xms;
  13. Babble (2018) • Matt S Trout氏作 • JavaScriptのBabelインスパイア • PPRを活用して最近のコードを古い

    Perl向けのコードに置換 • サブルーチンシグネチャの新旧切り 替えにも対応 • .pmcという拡張子のファイルを活用 すると新旧両用にも
  14. Perl 6について • 月々のリリースは続いています • 次のメジャーリリースとなる6.dが準備中 (予定では2018年11月のDiwali祭後に) • 書籍も続々と •

    最近ではCroというウェブアプリケーション フレームワークが話題 • IntelliJを利用したCommaというPerl 6用 IDEも登場(Early Beta)