Fireship · @fireship
Perl in 100 Seconds
Uploaded April 29, 2022 · Length 2:26
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.
- 0:00
Pearl a dynamic interpreted scripting
- 0:02
language famous for its powerful text
- 0:04
processing abilities it was developed in
- 0:06
1987 by Larry wall a linguist who
- 0:09
designed it to feel more like a human
- 0:10
language than a computer language when
- 0:12
someone says Pearl they're usually
- 0:13
talking about version 5. there was a
- 0:15
version 6 under development but it
- 0:17
evolved into another language called
- 0:18
Raku Pearl is often referred to as a
- 0:21
glue language and has been dubbed the
- 0:22
Swiss Army chainsaw of the Internet it's
- 0:24
most commonly used to write CGI scripts
- 0:26
that allow web servers to communicate
- 0:28
with external programs its powerful
- 0:30
string parsing abilities has made it the
- 0:32
language of choice on high traffic sites
- 0:34
like DuckDuckGo booking.com and
- 0:36
Craigslist syntactically it resembles C
- 0:38
but is far more compressed allowing
- 0:40
developers to write very tourist code
- 0:41
like one-liners that hack together a
- 0:43
solution much quicker than other
- 0:44
scripting languages like python it
- 0:46
contains a large collection of language
- 0:48
Primitives and a ton of shortcuts for
- 0:50
getting things done quickly you may find
- 0:51
it ugly and awkward but system
- 0:53
administrators love it because it gets
- 0:55
the job done to get started install the
- 0:57
Pearl interpreter then create a file
- 0:59
ending in.pl it's a scripting language
- 1:01
so we start with a shebang and point it
- 1:03
to the interpreter's binary declare a
- 1:05
variable with a dollar sign then print
- 1:07
it to the standard output and the
- 1:08
variable can be easily interpolated into
- 1:10
another string variables can be scoped
- 1:12
locally with the my keyword or globally
- 1:14
to an entire package with the hour
- 1:15
keyword the dollar sign creates a scalar
- 1:18
variable which is a single value like a
- 1:20
string or number if we change the dollar
- 1:21
sign to the at symbol this variable
- 1:23
becomes an array the index of any item
- 1:25
in the array can be accessed with
- 1:27
brackets now name the variable with a
- 1:28
percent sign to get a hash or key value
- 1:31
pair to access one of its Keys use
- 1:33
braces one of the design principles of
- 1:35
pearl is things that are different
- 1:37
should look different handle conditional
- 1:38
logic using IF or unless then make it
- 1:41
more concise by refactoring it to one
- 1:43
line then make it even more concise
- 1:44
using the ternary operator one of the
- 1:46
most unusual things about Pearl is that
- 1:48
your functions are defined as
- 1:49
subroutines instead of defining
- 1:51
parameters within parentheses like most
- 1:53
other languages any arguments passed to
- 1:55
the function can be accessed with the at
- 1:57
underscore array when it comes to
- 1:58
parsing text regex is built in and The


