Fireship · @fireship

Perl in 100 Seconds

Uploaded April 29, 2022 · Length 2:26

Perl in 100 Seconds

Summary

perl scripting language basics and features in 100 seconds, including text processing, variables, and functions.

  • perl scripting
  • text processing
  • programming language
  • scripting basics
  • perl features

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    Pearl a dynamic interpreted scripting

  2. 0:02

    language famous for its powerful text

  3. 0:04

    processing abilities it was developed in

  4. 0:06

    1987 by Larry wall a linguist who

  5. 0:09

    designed it to feel more like a human

  6. 0:10

    language than a computer language when

  7. 0:12

    someone says Pearl they're usually

  8. 0:13

    talking about version 5. there was a

  9. 0:15

    version 6 under development but it

  10. 0:17

    evolved into another language called

  11. 0:18

    Raku Pearl is often referred to as a

  12. 0:21

    glue language and has been dubbed the

  13. 0:22

    Swiss Army chainsaw of the Internet it's

  14. 0:24

    most commonly used to write CGI scripts

  15. 0:26

    that allow web servers to communicate

  16. 0:28

    with external programs its powerful

  17. 0:30

    string parsing abilities has made it the

  18. 0:32

    language of choice on high traffic sites

  19. 0:34

    like DuckDuckGo booking.com and

  20. 0:36

    Craigslist syntactically it resembles C

  21. 0:38

    but is far more compressed allowing

  22. 0:40

    developers to write very tourist code

  23. 0:41

    like one-liners that hack together a

  24. 0:43

    solution much quicker than other

  25. 0:44

    scripting languages like python it

  26. 0:46

    contains a large collection of language

  27. 0:48

    Primitives and a ton of shortcuts for

  28. 0:50

    getting things done quickly you may find

  29. 0:51

    it ugly and awkward but system

  30. 0:53

    administrators love it because it gets

  31. 0:55

    the job done to get started install the

  32. 0:57

    Pearl interpreter then create a file

  33. 0:59

    ending in.pl it's a scripting language

  34. 1:01

    so we start with a shebang and point it

  35. 1:03

    to the interpreter's binary declare a

  36. 1:05

    variable with a dollar sign then print

  37. 1:07

    it to the standard output and the

  38. 1:08

    variable can be easily interpolated into

  39. 1:10

    another string variables can be scoped

  40. 1:12

    locally with the my keyword or globally

  41. 1:14

    to an entire package with the hour

  42. 1:15

    keyword the dollar sign creates a scalar

  43. 1:18

    variable which is a single value like a

  44. 1:20

    string or number if we change the dollar

  45. 1:21

    sign to the at symbol this variable

  46. 1:23

    becomes an array the index of any item

  47. 1:25

    in the array can be accessed with

  48. 1:27

    brackets now name the variable with a

  49. 1:28

    percent sign to get a hash or key value

  50. 1:31

    pair to access one of its Keys use

  51. 1:33

    braces one of the design principles of

  52. 1:35

    pearl is things that are different

  53. 1:37

    should look different handle conditional

  54. 1:38

    logic using IF or unless then make it

  55. 1:41

    more concise by refactoring it to one

  56. 1:43

    line then make it even more concise

  57. 1:44

    using the ternary operator one of the

  58. 1:46

    most unusual things about Pearl is that

  59. 1:48

    your functions are defined as

  60. 1:49

    subroutines instead of defining

  61. 1:51

    parameters within parentheses like most

  62. 1:53

    other languages any arguments passed to

  63. 1:55

    the function can be accessed with the at

  64. 1:57

    underscore array when it comes to

  65. 1:58

    parsing text regex is built in and The