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

perl_in_2024winter.pdf

Kenichi Ishigaki
March 17, 2024
6

 perl_in_2024winter.pdf

Kenichi Ishigaki

March 17, 2024
Tweet

Transcript

  1. me 2016年のPerl@LLoT Perl in 2016@YAPC::Hokkaido 2017年春のPerl@YAPC::Kansai 2017年夏のPerl@YAPC::Fukuoka (萬國之津梁@YAPC::Okinawa) (2018年初夏のPerl5)@Hokkaido.pm #14

    2018年夏のPerl5@Shibuya.pm #18 2018年残暑のPerl@LL2018 2019年冬のPerl@YAPC::Tokyo (Learn Languages 2021) 2023年春のPerl@YAPC::Kyoto 2024年冬のPerl@YAPC::Hiroshima <- イマココ
  2. 背景事情 欧米でサイバーセキュリティ関連の法整備が進んでいる • EO 14028 (2021/05) • NIS2 Directive &

    Cyber Resilience Act 「CPANをもっと安全にしておかないといろいろヤバイ」 CPAN Security Working Group (2023/04) https://security.metacpan.org
  3. Perl本体のセキュリティリリース 2023年11月に5.38.2、5.36.3、5.34.3が出ました • CVE-2023-47038 - Write past buffer end via

    illegal user-defined Unicode property • CVE-2023-47039 - Perl for Windows binary hijacking vulnerability
  4. クラス Perl本体でもクラスの実装が始まっています use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)

    { field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } }
  5. クラス 新しいキーワードはclass、field、method(と未実装のrole)のみ use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)

    { field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } }
  6. クラス 属性を多用するようになっています use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)

    { field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } }
  7. クラス method内の$selfなどは自動的に用意されます use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)

    { field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } }
  8. クラス サブルーチンシグネチャにも対応 use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)

    { field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } }
  9. builtin::export_lexically 特定のブロックのみにエクスポートできる 機能が用意されました package My::Util; use v5.38; use experimental qw(builtin);

    sub import { my $class = shift; my %export = map { $_ => $class->can($_) // die "Can't export $_" } @_; builtin::export_locally %export; } sub foo { say "foo" }
  10. __CLASS__ キーワード (5.39.2) $selfが使えない場所で使うと便利? class Foo { use constant DEFAULT_X

    => 10; field $x = __CLASS__->DEFAULT_X; method say_x { say $x } } class Bar :isa(Foo) { use constant DEFAULT_X => 20; } Foo->new->say_x; # 10 Bar->new->say_x; # 20
  11. __CLASS__ キーワード (5.39.2) methodはインスタンスからは呼べないので要注意 class Foo { field $x =

    __CLASS__->default_x; # ERROR! method default_x { 10 } method say_x { say $x } } class Bar :isa(Foo) { method default_x { 20 } }
  12. builtin::load_module (5.39.5) バージョン指定はVERSIONメソッドで use v5.39.5; use builtin 'load_module'; use experimental

    'builtin'; for my $module (keys $config->{prereq}->%*) { load_module $module; if (my $version = $config->{prereq}{$module}) { $module->VERSION($version); } }
  13. returnと間接オブジェクト (5.39.6) no bareword::filehandlesでも止められません (used only onceの警告が出るようにはなります) use v5.38; no

    bareword::filehandles; # use List::Util 'sum'; sub my_sum { return sum grep $_ > 0, @_ } say my_sum(-1, 2, 3); # *main::sum23
  14. 特殊変数の別名 うっかり読み込むと正規表現が遅くなってしまう Englishモジュールの代わりに local ${^ARG}; # $_ my $pid =

    ${^PID}; # $$ my $error = ${^EVAL_ERROR}; # $@ my %signals = %{^SIG}; # %SIG https://github.com/Perl/PPCs/blob/main/ppcs/ppc0014-english-aliases.md
  15. 文字列テンプレート "foo @{[$bar->baz]}"のようなハックはありますが… # No interpolation qt{Greetings}; # Simple scalar

    interpolation qt<Greetings, {$title} {$name}>; # Interpolation of method calls qt"Greetings, {$user->title} {$user->name}"; # Interpolation of various expressions qt{It has been {$since{n}} {$since{units}} since your last login}; qt{...a game of {join q{$"}, $favorites->{game}->name_words->@*}}; https://github.com/Perl/PPCs/blob/main/ppcs/ppc0019-qt-string.md
  16. 条件付き矢印演算子 左辺が定義済みなら普通の矢印演算子、 未定義ならそこで処理を打ち切り全体をないものに # $val = defined $foo && defined

    $foo->{bar} ? $foo->{bar}[3] : (); $val = $foo?->{bar}?->[3]; # @vals = defined $aref ? $aref->@* : (); @vals = $aref?->@*; # note that @vals is (), not (undef). # my $class = 'SomeClass'; $class->new if defined $class; my $class = 'SomeClass'; $class?->new; https://github.com/Perl/PPCs/blob/main/ppcs/ppc0021-optional-chaining-operator.md
  17. メタプログラミング metaモジュールを使った実験が始まっています use v5.14; use meta; my $metapkg = meta::get_package(

    "MyApp::Some::Package" ); $metapkg->add_symbol( '&a_function' => sub { say "New function was created" } ); MyApp::Some::Package::a_function(); https://metacpan.org/pod/meta https://github.com/Perl/PPCs/blob/main/ppcs/ppc0022-metaprogramming.md
  18. ツールチェーンのサポート下限 従来はPerl 5.8.1(2003/09)が下限でした https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md Lancaster Consensus (2013) Going forward, the

    Perl toolchain will target Perl 5.8.1, released September 2003. This will allow toolchain modules to reliably use PerlIO and improved Unicode support.
  19. ツールチェーンのサポート下限 2023年4月のToolchain Summitで改正されました Lyon Amendment (2023) https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lyon-amendment.md No new release

    of a distribution in the Perl toolchain will specify a minimum perl prerequisite version (whether configure, build, runtime, or test) that has been available for less than ten years. 「リリース後10年未満のPerlをサポート下限とすることはない」
  20. ツールチェーンのサポート下限 • いまは例外的に2012年リリースのPerl 5.16をサポート • 2024年6月にRHEL/CentOS 7が退役したら、 2014年リリースの5.20より古いPerlへのインストールは 保証されなくなっていきます •

    今後は毎年無条件に上がっていくので、 CIなどで旧版のサポートをするときは要注意 • 古いPerlには古いバージョンのモジュールをインストール できるようにするという話も出てはいますが…
  21. 2024年の主要Perl関連イベント • German Perl/Raku-Workshop (4/15~17, Frankfurt, Germany) https://www.perl-workshop.de • Perl

    Toolchain Summit 2024 (4/25~28, Lisbon, Portugal) • The Perl and Raku Conference 2024 (6/25~27, Las Vegas, NV) https://tprc.us/tprc-2024-las/