Read the route backward
Before you start this advanced track
Arrays, hashes, and regular expressions. Expect sigils, capture groups, and scalar/list context.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
An array preserves the order of a route through a building. reverse produces a reversed list when assigned to an array. An array slice then selects its first two entries, using zero-based positions, and join connects those entries with an arrow. The original visits array remains available in its original order.
use strict;use warnings;my @visits = ("desk", "studio", "roof", "cafe");my @recent = reverse @visits;my $report = join(" > ", @recent[0, 1]);print "$report\n";Each mission is a complete Perl 5 script. Run one with perl. The scripts enable strict and warnings and use only built-in features; no modules, files, or external commands are needed.
Track the values line by line. Predict the result before running this example in your own editor.