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
360
postfix dereference 徹底攻略 / effective postfix dereference
Gotanda.pm #16
mackee
March 30, 2018
Tweet
Share
More Decks by mackee
See All by mackee
ワンバイナリWebサービスのススメ
mackee
10
7.8k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
100
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
650
perl for shell, awk and sed programmers
mackee
2
2.2k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
610
database/sqlでNullを扱う歴史とsql.Null[T]の登場 / sql.Null[T] history
mackee
0
510
マイクロサービス化を利用した Goへの移行事例
mackee
0
630
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
4.5k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.9k
Other Decks in Programming
See All in Programming
XP, Testing and ninja testing
m_seki
3
180
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
Go1.25からのGOMAXPROCS
kuro_kurorrr
1
800
GraphRAGの仕組みまるわかり
tosuri13
7
480
Gleamという選択肢
comamoca
6
760
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
220
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
140
ドメインモデリングにおける抽象の役割、tagless-finalによるDSL構築、そして型安全な最適化
knih
11
2k
Team operations that are not burdened by SRE
kazatohiei
1
190
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
490
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
410
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Building Applications with DynamoDB
mza
95
6.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Balancing Empowerment & Direction
lara
1
360
Mobile First: as difficult as doing things right
swwweet
223
9.7k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
We Have a Design System, Now What?
morganepeng
53
7.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.3k
A better future with KSS
kneath
239
17k
The Pragmatic Product Professional
lauravandoore
35
6.7k
KATA
mclloyd
29
14k
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ʹ্͛Δͱ͜Ζ͔Β……