#!/usr/bin/perl use LWP::Simple; $file = get "http://www.cs.umd.edu/~golbeck/perl/enron.csv"; @lines = split(/\n/,$file); $count = 0; foreach $line (@lines) { ($to,$from) = split(/,/,$line); #here's some shorthand we haven't seen. the two bars mean OR #so this checks to see if either the to or from equal the #address we want. However, it's just fine to have two if #statement, one checking the to and the other checking the from if ($to eq "taylor\@enron.com" || $from eq "taylor\@enron.com") { $count++; } } print "There are $count emails from taylor\@enron.com\n"; #tricky extension $count2=0; #start the same way foreach $line (@lines) { ($to,$from) = split(/,/,$line); #now, we're going to split the address on the @ sign. ($before_the_at, $after_the_at) = split(/@/,$to); #and we can see if the stuff after the @ is enron.com if ($after_the_at ne "enron.com") { $count2++; } #repeat it for the from address ($before_the_at, $after_the_at) = split(/@/,$from); if ($after_the_at ne "enron.com") { $count2++; } } print "There are $count2 addresses that are not enron.com addresses\n";