sub DraftHISTORY{
my $url = 'http://www.hockeydb.com/ihdb/draft/teams/dr00008756.html';
my @ret;
my $data = download( $url );
my ($div) = ( $data =~ /
Vancouver Canucks Draft History<\/div>(.*)<\/div>/s ); # every "/" inside needs "\"
my @stats = ( $div =~ /
(.*?)<\/tr>/gs ); # we have $div, now we pick every row (/g) into @stats
shift @stats;
my $yearcnt = 2015;
return 'an error occured.' if( @stats<=0 );
my $formatheader = "%-30s %90s";
my $format = "%-10s %-5s %-7s %-30s %-3s %-50s %-3s %-3s %-3s %-5s %-5s";
push @ret, "\x02\x1F" . sprintf($formatheader, ("Canucks Draft History", "NHL Totals"));
push @ret, "\x02\x1F" . sprintf($format, ("Draft", "Num.", "Round", "Player", "Pos", "Drafted From", "GP", "G", "A", "Pts", "PIM")) . "\x02\x1F";
foreach( @stats ) {
my ($Draft, $Num, $Round, $Player, $Pos, $Drafted, $Games, $Goals, $Assists, $Points, $PIM) =
( /(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*(.*?)<\/td>\s*/ );
($Draft) = ( $Draft =~ /(.*?)<\/a>/ );
($Player) = ( $Player =~ /(.*?)<\/a>/ );
push @ret, sprintf($format, ($Draft, $Num, $Round, $Player, $Pos, $Drafted, $Games, $Goals, $Assists, $Points, $PIM));
last if ($Draft == $yearcnt);
}
return @ret
}