(2) For example,
use strict;
#
# K. Yue
# Suggested Solution to Q2, HW#1, CSCI 4230,
Summer 2001
#
my $filename = "words.txt";
open(IN, "<$filename") or die "Can't open
file $filename";
print "All words from the dictionary $filename
that are also words if the last character is removed.\n\n";
my %words = ();
my $temp = "";
while ($_ = <IN>) {
chomp;
$_ = lc $_;
$temp = $_;
chop $temp;
print "$_\n" if $words{$temp};
$words{$_}++;
}
exit 0;
(3) For example,
perl -ne "chop; print qq($1: ) if /<document_url>(.*?)<\/document_url>/;
print qq($1.\n) if /<harvest_time>(.*?)<\/harvest_time>/;" news.xml