Downloads

In several parts of Learning Perl, we present some programs or data that we’d like you to use. Instead of making you type in these programs by hand, we make them available here so not only do you save time, but we save time by not having to help you figure out which characters you missed or transposed.

You can get the compressed set of files from Github, or look at them individually in the Github repository.

Here’s a few quick things that you can download right away:

Chapter 8, Regular Expressions

The regular expression test program shows you want part of a string matched and what didn’t:

#!/usr/bin/perl
while (<>) {                   # take one input line at a time
	chomp;
	if (/YOUR_PATTERN_GOES_HERE/) {
		print "Matched: |$`<$&>$'|\n";  # the special match vars
	} else {
		print "No match: |$_|\n";
	}
}

Chapter 14, Strings and Sorting

Here’s a list of numbers that you can use for Exercise 1:

17 1000 04 1.50 3.14159
-10 1.5 4 2001 90210 666
9 0 2 1 0
2001 42 -40 98.6 2.71828

Here’s a hash of mixed-cased names you need for Exercise 2:

my %last_name = qw{ 
	fred flintstone Wilma Flintstone Barney Rubble
	betty rubble Bamm-Bamm Rubble PEBBLES FLINTSTONE
};

Chapter 16, Process Management

If you don’t have the Unix date command, here’s a pure Perl version that can fake it for you. Name it date and put it somewhere in your path:

my $date = localtime;

print "$date\n";