use strict; use warnings; use LWP::Simple; use HTML::TokeParser; my $url = "http://www.xecu.net/fantasy/index.shtml"; my $page = get($url); my $p = HTML::TokeParser->new(\$page) || die "problem: $!\n"; #### use strict; use warnings; my $delta = int(shift); my $delta_years = int(abs($delta)/12); my $delta_months = abs($delta) % 12; my $cur_month = (localtime)[4]; my $cur_year = (localtime)[5]+1900; if ($delta < 0) { $delta_years *= -1; $delta_months *= -1; } if ($delta_months < 0) { if (abs($delta_months) > $cur_month) {$delta_years--;} } else { if ($delta_months > (12 - $cur_month)) {$delta_years++;} } my $new_month = $cur_month + $delta_months; my $new_year = $cur_year + $delta_years; my @days = qw(31 28 31 30 31 30 31 31 30 31 30 31); my @months = qw(January February March April May June July August September October November December); my $answer = $days[$new_month]; if (($new_month == 2) && (Is_Leap_Year($new_year))) {$answer = 29;} print "$months[$new_month] has $answer days.\n"; ########### sub Is_Leap_Year { my $year = shift; if (($year % 100) == 0) {return 1;} if (($year % 4) == 0) { if (($year % 25) == 0) { return 0; } else {return 1;} } else {return 0;} } #### use strict; my $file; open(FH,"<",$file) || die "Unable to open file: $!\n"; { local $/; $file = ; } close(FH); #### use strict; my @lc_alpha = ('a'..'z'); foreach my $file (@ARGV) { my $error = 0; my %count; foreach my $alpha (@lc_alpha) {$count{$alpha} = 0;} open(DAT,"<",$file) || $error++; if ($error) { print "Unable to open file '$file': $!\n"; print "Skipping the file.\n"; } else { while () { my (@chars) = ($_ =~ m/([a-z])/gi); foreach my $char (@chars) { $count{lc($char)}++; } } close(DAT); print "The file '$file' has the following character counts:\n"; foreach my $alpha (@lc_alpha) { print " $alpha -- $count{$alpha}\n"; } print "\n"; } }