]> Dogcows Code - chaz/talk-level-up-your-perl/blobdiff - slides.html
improve notes
[chaz/talk-level-up-your-perl] / slides.html
index 4f97d8d11078cfa1c7af9f08688409b8997bcc47..c7b48e8f4559b01f9da5a3b7a088cce705a7d6bd 100644 (file)
@@ -8,6 +8,20 @@ name:   title
 
 Charles McGarvey
 
+???
+- Hi. I'm Charles McGarvey.
+- Been a Perl programmer for a long time...
+
+---
+class: center, middle
+
+![The Raptor](img/raptor.png)
+
+???
+- Deciding what to talk on... everything!
+- List of things that you should know or be aware of...
+- This image works well (merit badge)...
+
 ---
 class:  center, middle
 name:   endurance
@@ -16,10 +30,9 @@ name:   endurance
 
 ### https://jobs.endurance.com/bluehost
 
----
-class: center, middle
-
-![The Raptor](img/raptor.png)
+???
+- My employer is hiring.
+- It's a pretty cool employer...
 
 ---
 class: center, middle
@@ -27,8 +40,8 @@ class: center, middle
 ## Use [`B::Deparse`](https://metacpan.org/pod/B::Deparse).
 
 ???
-`B::Deparse` is a backend module for the compiler. It takes the parse tree after compiling and generates Perl code from
-it.
+- `B::Deparse` is a backend module for the compiler.
+- It takes the parse tree after compiling and generates Perl code from it.
 
 So, why compile Perl only to turn it back into Perl?
 It is useful for checking that perl and you are both understanding the code the same way.
@@ -36,7 +49,7 @@ It is useful for checking that perl and you are both understanding the code the
 ---
 class: ex-deparse
 
-## Example: Use the `-p` flag to understand precedence
+## Example of `B::Deparse`.
 
 ```bash
 perl -MO=Deparse,-p -e'$a && not $b && not $c'
@@ -44,6 +57,7 @@ perl -MO=Deparse,-p -e'$a && not $b && not $c'
 -e syntax OK
 ```
 
+--
 ```bash
 perl -MO=Deparse,-p -e'$a && ! $b && ! $c'
 *(($a and not($b)) and not($c));
@@ -51,106 +65,14 @@ perl -MO=Deparse,-p -e'$a && ! $b && ! $c'
 ```
 
 ???
-These example snippets demonstrate an actual bug found in real code.
-
-The first snippet is mixing high and low-precedence logical operators. Comparing the output of Deparse, it's fairly
-clear to see that these are not doing the same thing.
-
-Deparse supports other flags that may be useful. Read the pod to find out more.
-
-Aside: Be careful about mixing high and low-precedence logical operators.
-
----
-class: ex-shellpod
-
-## Document your shell scripts with pod.
-
-```bash
-#!/bin/sh
-
-: <<'=cut'
-=head1 NAME
-
-therapist.sh - This script can save you a bunch of cash
+- These example snippets demonstrate an actual bug found in real code.
 
-=cut
-
-echo 'Hello. Now, tell me about your problems.'
-
-while read response
-do
-    printf "Patient said: %s" "$response" >>therapist_notes.txt
+- The first snippet is mixing high and low-precedence logical operators. Comparing the output of Deparse, it's fairly
+  clear to see that these are not doing the same thing.
 
-    echo 'And how did that make you feel?'
-done
+- Deparse supports other flags that may be useful. Read the pod to find out more.
 
-echo "Goodbye! Let's meet again in two weeks."
-```
-
----
-class: ex-shellpod
-
-## Document your shell scripts with pod.
-
-```bash
-#!/bin/sh
-
-: <<'=cut'
-*=head1 NAME
-*
-*therapist.sh - This script can save you a bunch of cash
-*
-*=cut
-
-echo 'Hello. Now, tell me about your problems.'
-
-while read response
-do
-    printf "Patient said: %s" "$response" >>therapist_notes.txt
-
-    echo 'And how did that make you feel?'
-done
-
-echo "Goodbye! Let's meet again in two weeks."
-```
-
-???
-It's pod! In a shell script.
-
----
-class: ex-shellpod
-
-## Document your shell scripts with pod.
-
-```bash
-#!/bin/sh
-
-*: <<'=cut'
-=head1 NAME
-
-therapist.sh - This script can save you a bunch of cash
-
-=cut
-
-echo 'Hello. Now, tell me about your problems.'
-
-while read response
-do
-    printf "Patient said: %s" "$response" >>therapist_notes.txt
-
-    echo 'And how did that make you feel?'
-done
-
-echo "Goodbye! Let's meet again in two weeks."
-```
-
-???
-This is the key right here. Anybody know what this is?
-
-It's a heredoc.
-
-The colon command in bourne shell is just noop. Sometimes you'll see the colon used as a type of comment, but unlike
-a comment the shell does parse the arguments to colon.
+- Aside: Be careful about mixing high and low-precedence logical operators.
 
 ---
 class: center, middle
@@ -158,7 +80,8 @@ class: center, middle
 ## Know regular expressions.
 
 ???
-Like, really know them.
+- Like, really know them.
+- I meet a lot of people who don't know regexp.
 
 ---
 class: center, middle
@@ -166,8 +89,9 @@ class: center, middle
 ### It's easy.
 
 ???
-All you have to do in order to read and write regular expressions *without looking at a help resource every time* is
-know the X parts of a regular expression.
+- But they're easy!
+- All you have to do in order to read and write regular expressions *without looking at a help resource every time* is
+  know a few basic things.
 
 ---
 class: center, middle
@@ -177,7 +101,8 @@ class: center, middle
 # (what to match) (how many to match)
 
 ???
-Regular expressions let you match strings.
+- Regular expressions let you match strings.
+- Find out "does a string follow a specific pattern".
 
 ---
 ### What to match: Literals
@@ -215,15 +140,19 @@ Regular expressions let you match strings.
 ---
 class: center, middle
 
-### That's it! Just:
-
 # (what to match) (how many to match)
 
+???
+- That's it!
+
 ---
 class: center, middle
 
 ## Okay, there is more...
 
+???
+- But if you know just those concepts, you can already read a large number of regexp that you'll come across.
+
 ---
 ### Boundaries
 
@@ -465,6 +394,97 @@ By the way, Vim supports embedded interpreters for other languages like Python,
 ---
 class: center, middle
 
+## Document your shell scripts with pod.
+
+---
+class: ex-shellpod
+
+```bash
+#!/bin/sh
+
+: <<'=cut'
+=head1 NAME
+
+therapist.sh - This script can save you a bunch of cash
+
+=cut
+
+echo 'Hello. Now, tell me about your problems.'
+
+while read response
+do
+    printf "Patient said: %s" "$response" >>therapist_notes.txt
+
+    echo 'And how did that make you feel?'
+done
+
+echo "Goodbye! Let's meet again in two weeks."
+```
+
+---
+class: ex-shellpod
+
+```bash
+#!/bin/sh
+
+: <<'=cut'
+*=head1 NAME
+*
+*therapist.sh - This script can save you a bunch of cash
+*
+*=cut
+
+echo 'Hello. Now, tell me about your problems.'
+
+while read response
+do
+    printf "Patient said: %s" "$response" >>therapist_notes.txt
+
+    echo 'And how did that make you feel?'
+done
+
+echo "Goodbye! Let's meet again in two weeks."
+```
+
+???
+It's pod! In a shell script.
+
+---
+class: ex-shellpod
+
+```bash
+#!/bin/sh
+
+*: <<'=cut'
+=head1 NAME
+
+therapist.sh - This script can save you a bunch of cash
+
+=cut
+
+echo 'Hello. Now, tell me about your problems.'
+
+while read response
+do
+    printf "Patient said: %s" "$response" >>therapist_notes.txt
+
+    echo 'And how did that make you feel?'
+done
+
+echo "Goodbye! Let's meet again in two weeks."
+```
+
+???
+This is the key right here. Anybody know what this is?
+
+It's a heredoc.
+
+The colon command in bourne shell is just noop. Sometimes you'll see the colon used as a type of comment, but unlike
+a comment the shell does parse the arguments to colon.
+
+---
+class: center, middle
+
 ## Understand calling context.
 
 ???
@@ -1413,57 +1433,66 @@ sub launch_missile ( $silo_id = get_default_silo_id() ) {
 ---
 class: ex-newfeatures
 
-## Try some newer perl5 features.
+### Postfix dereferencing
 
 ```perl
-*use v5.24;
-*use feature qw(signatures);    # available in v5.20
-*no warnings qw(experimental::signatures);
-
-my $missile_inventory = {
-    ID  => 20,
-    WY  => 25,
-    CA  => 195,
-};
+use v5.24;
 
-*sub get_default_silo_id () {
-    return $_ if 0 < $missile_inventory->{$_} for (sort keys $missile_inventory->%*);
-    die "No more missiles. :-(\n";
+my $person = {
+    name => 'Bob',
+    associates => [
+        {
+            name => 'Karen',
+        },
+        {
+            name => 'Doug',
+        },
+    ],
 }
 
-*sub launch_missile ( $silo_id = get_default_silo_id() ) {
-    die "Silo is empty.\n" if $missile_inventory->{$silo_id} <= 0;
-    $missile_inventory->{$silo_id} -= 1;
-    say "Missile launched from silo $silo_id.";
-}
+my @others = $person->{associates}->@*;
+my %associate_attributes = $person->{associates}->@[0]->%*;
 ```
 
+### `@{...}` can be `->@*` at the end
+### `%{...}` can be `->%*` at the end
+
 ---
-class: ex-newfeatures
+class: ex-newfeatures2
 
-## Try some newer perl5 features.
+### Subroutine signatures
 
 ```perl
-use v5.24;
-use feature qw(signatures);    # available in v5.20
+use v5.20;
+use feature qw(signatures);
 no warnings qw(experimental::signatures);
 
-my $missile_inventory = {
-    ID  => 20,
-    WY  => 25,
-    CA  => 195,
-};
+sub only_one_arg($foo) {
+}
 
-sub get_default_silo_id () {
-*   return $_ if 0 < $missile_inventory->{$_} for (sort keys $missile_inventory->%*);
-    die "No more missiles. :-(\n";
+sub other_args_allowed_and_ignored($foo, @) {
 }
 
-sub launch_missile ( $silo_id = get_default_silo_id() ) {
-    die "Silo is empty.\n" if $missile_inventory->{$silo_id} <= 0;
-    $missile_inventory->{$silo_id} -= 1;
-    say "Missile launched from silo $silo_id.";
+sub positional_and_named($args, %other) {
 }
+
+# etc.
+```
+
+---
+class: ex-newfeatures2
+
+### Strip leading space in heredocs
+
+```perl
+use v5.26;
+
+do {
+    print <<~'HERE';
+    Hi. The text here is indented in the source code,
+    but not in the console!
+    HERE;
+};
 ```
 
 ---
@@ -1668,10 +1697,10 @@ As this example shows, you can also do nifty stuff like destructure.
 
 .col[
 - Use [`B::Deparse`](https://metacpan.org/pod/B::Deparse).
-- Document your shell scripts with pod.
 - Know regular expressions.
 - Use [`Regexp::Debugger`](https://metacpan.org/pod/Regexp::Debugger).
 - Write Vim plugins in Perl.
+- Document your shell scripts with pod.
 - Understand calling context.
 - Understand execution phases.
 - Know when to be terse and when not to.
This page took 0.027602 seconds and 4 git commands to generate.