Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
postfix dereference 徹底攻略 / effective postfix dereference
mackee
March 30, 2018
Programming
1
210
postfix dereference 徹底攻略 / effective postfix dereference
Gotanda.pm #16
mackee
March 30, 2018
Tweet
Share
More Decks by mackee
See All by mackee
じわじわとPerlからGoに移行しようとしている俺達のマイクロサービシーズの紹介 / The migrating to microservices in Go from Monolith in Perl
mackee
2
1k
Mojoliciousで書いて理解するhotwireの仕組み
mackee
0
4.1k
GraphQLサーバを作る苦しみと解決手法
mackee
16
8.5k
ChatBotの重いタスクをCircleCIに持っていってみた / How to move heavy tasks on ChatBot to CircleCI
mackee
1
3.8k
ゲームのマスタデータ特有の3つの困難と、カヤックでの解決方法 / How to solve three problems when handling the master-data of mobile games
mackee
3
10k
設計した自作キーボードの基板を中国で小ロット量産するときの 苦労、涙、理由 / How to "build" the PCB of keyboard
mackee
2
6.3k
電子基板を快適に作るためのキーボードの電子基板を作る技術 / Build my keyboard for my keyboard
mackee
0
4.5k
ゲームのサーバサイドエンジニアをやっていく技術 / The technology of game server side engineer
mackee
1
4.4k
package名と変数名がかぶっているのをとにかく検出したい / I need detect to conflicts of identifier for Go
mackee
3
6.1k
Other Decks in Programming
See All in Programming
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
140
人類には難しいZynqで組み込みRust
ikemori
0
480
microCMS × imgixを活用して品質とレスポンスを両立したポートフォリオサイトを作成した話
takehitogoto
0
390
tfcon2022_Web3Dひとめぐり.pdf
emadurandal
0
750
New Relicを使った Observabilityの実現方法と活用例 / gocon 2022 spring after talk
budougumi0617
0
960
iOSアプリの技術選択2022
tattn
6
2.2k
Explore Java 17 and beyond
josepaumard
3
630
偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scripting Language
lovee
1
170
TDX22: User-Mode DB Ops
ca_peterson
3
1.1k
Let's make a contract: the art of designing a Java API
mariofusco
0
160
heyにおけるSREの大切さ~マルチプロダクト運用の「楽しさ」と「難しさ」および今後の展望~
fufuhu
3
1.5k
Reactでアプリケーションを構築する多様化
sakito
4
3.1k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
180k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
151
12k
Pencils Down: Stop Designing & Start Developing
hursman
112
9.8k
Teambox: Starting and Learning
jrom
121
7.6k
Done Done
chrislema
174
14k
5 minutes of I Can Smell Your CMS
philhawksworth
196
18k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Fontdeck: Realign not Redesign
paulrobertlloyd
73
4.1k
Building Flexible Design Systems
yeseniaperezcruz
310
33k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
Creatively Recalculating Your Daily Design Routine
revolveconf
205
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
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ʹ্͛Δͱ͜Ζ͔Β……