[Purdue-pm] Perl 5 exercise

Mark Senn mark at purdue.edu
Sat Nov 8 20:39:19 PST 2014


The first half of this exercise shows the results of the computation.
In the second half of the exercise replace "THIS" with ten characters
that more clearly expresses the code in the first half of the
exercise.





#!/usr/new/bin/perl

my $line = 'Al <adam at a.com>, Bob B. Bob <bob at e.gov>, Bono <bono at u2.com>';


$_ = $line;
s/^.+?<//;
s/>$//;
my @email = split />.+?</;

print "first try\n";
map  { print "($_)\n" }  @email;


$_ = $line;
# Replace THIS with ten characters that will produce the same answer as
# above, and in my opinion more clearly expresses what you're trying to do.
@email = THIS;

print "second try\n";
map  { print "($_)\n" }  @email;


More information about the Purdue-pm mailing list