Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
postfix dereference 徹底攻略 / effective postfix de...
Search
mackee
March 30, 2018
Programming
1
350
postfix dereference 徹底攻略 / effective postfix dereference
Gotanda.pm #16
mackee
March 30, 2018
Tweet
Share
More Decks by mackee
See All by mackee
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
61
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
320
perl for shell, awk and sed programmers
mackee
2
1.8k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
250
database/sqlでNullを扱う歴史とsql.Null[T]の登場 / sql.Null[T] history
mackee
0
180
マイクロサービス化を利用した Goへの移行事例
mackee
0
310
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.8k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.9k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
mackee
0
1.4k
Other Decks in Programming
See All in Programming
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1.1k
Go 1.24でジェネリックになった型エイリアスの紹介
syumai
1
220
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
200
GAEログのコスト削減
mot_techtalk
0
120
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.4k
バッチを作らなきゃとなったときに考えること
irof
2
460
Unity Android XR入門
sakutama_11
0
170
時計仕掛けのCompose
mkeeda
1
310
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
8
1.8k
Rails アプリ地図考 Flush Cut
makicamel
1
130
Grafana Cloudとソラカメ
devoc
0
180
Featured
See All Featured
Speed Design
sergeychernyshev
27
800
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
560
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Transcript
postfix dereference పఈ߈ུ @mackee_w a.k.a macopy Gotanda.pm #16
୭ˠ • twitter: @mackee_w • GitHub: mackee • kuiperbelt/kuiperbelt :
WebSocketศར܅ • ࠷ۙPerl Hackers Hubʹςετͱ͔ͷهࣄΛॻ ͍ͨ
postfix dereference ͬͯԿ
postfix dereference $hashref->%* $arrayref->@*
postfix dereference $hashref->%* $arrayref->@*
postfix dereference $hashref->%* $arrayref->@*
ղઆ
postfix dereference %{$hashref} || $hashref->%*
postfix dereference @{$arrayref} || $arrayref->@*
postfix ɹ= έπʹͭ͘ dereference ɹ= σϦϑΝϨϯε ུ: postderef
֗ͷ ಡΊͳ͍ ͜Εศརʂ
ϝϦο τ
ϝϦοτ • ߦͬͯʙฦͬͯͬͯͳΒͳ͍ %{$aaa->{bbb}} $aaa->{bbb}->%* 1 2 3 4 5
6 7 1 2 3 4 5 6
σϝϦοτ
……ͳΜͰ ه߸૿ͪ͠Όͬͨͷʁ
͓٬༷ɺ ه߸૿͓ͯ͠Γ·ͤΜɺ ه߸ͷΈ߹ΘͤΛ૿ͨ͠ ͚ͩͳͷͰ͢……
Έ߹Θͤ……
୭͕ * ͚ͩͩͱݴͬͨ
hash slicing my $hashref = { k1 => "v1", k2
=> "v2", k3 => "v3" }; # ී௨ͷσϦϑΝϨϯε͔ΒͷϋογϡεϥΠε my ($v1, $v3) = @{$hashref}{qw/k1 k3/}; # postderefͰϋογϡεϥΠε my ($v1, $v3) = $hashref->@{qw/k1 k3/};
࣮࣭JSͷobject destructuringͰʁʁʁ ※ӈลʹॻ͔ͳ͍ͱ͍͚ͳ͍ͷͰҧ͍·͢ https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
·ͱΊ • ʢͱख͕֮͑Εʣศར • *͚ͩͰͳ͍ɻΉ͠ΖͦΕҎ֎͕ศར • v5.24͔Βexperimental֎Εͨɻ͑· ͢ʂʂʂʂ • ࠓճͷίʔυશ෦use
v5.24.0;ͯ͠·͢
http://perldoc.jp/docs/perl/5.24.0/perl5240delta.pod
postderef_qqͬͯͳʹ
postderef_qq my $hashref = { k1 => “v1", k2 =>
"v2", k3 => "v3" }; print "[$hashref->@{qw/k1 k3/}]\n"; # => [v1 v3]
ͳΔ΄Ͳͳʁ
csvΈ͍ͨʹग़ͨ͠Γ my @columns = qw/c1 c2 c3/; my $data =
[ { c1 => "aa", c2 => "bb", c3 => "cc" }, { c1 => "dd", c2 => "ee", c3 => "ff" }, { c1 => "gg", c2 => "hh", c3 => "ii" }, ]; $" = ","; print "@columns\n"; print "$_->@{@columns}\n" for @$data;
csvΈ͍ͨʹग़ͨ͠Γ $ perl postderef.pl c1,c2,c3 aa,bb,cc dd,ee,ff gg,hh,ii
Ͳ͏Αʁʁʁʁ
ײ • ϫϯϥΠφʔͱ͔Ͱศརͦ͏ • jqͷΘΓʹ͏ͱ͔ • ͱ͍͑·ͣv5.24ʹ্͛Δͱ͜Ζ͔Β……