While reading the regex portion of Apress’s Beginning Perl Second Edition by James Lee, the following sample code totally made my day.


#!/usr/bin/perl -w
use strict;

$_ = "There are two major products that came out of Berkeley: LSD and UNIX";

s/(\w+)\s+(\w+)/$2 $1/;

$_ = ucfirst($_);
print $_, "?\n";