2 # Quote.pl: retrieve stock quotes from yahoo
3 # heavily based on Slashdot.pl
5 # Author: Michael Urman <mu@zen.dhis.org>
7 # changes from Morten Brix Pedersen (mbrix) and Tim Riker <Tim@Rikers.org>
16 $input = reverse $input;
17 $input =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
18 return scalar reverse $input;
23 my @results = &::getURL("http://quote.yahoo.com/d/quotes.csv" .
24 "?s=$stock&f=sl1d1t1c1ohgv&e=.csv");
27 if (!scalar @results) {
28 &::msg($::who, "i could not get a stock quote :(");
32 foreach my $result (@results) {
33 # get rid of the quotes
36 my ($ticker, $recent, $date, $time, $change, $open,
37 $high, $low, $volume) = split(',',$result);
40 # "+ 0" removes trailing cr/lf/etc.
41 my $newvol = commify($volume + 0);
43 $reply .= ' ;; ' if $reply;
44 $reply .= "$ticker: $recent ($high/$low), $date $time, " .
45 "Opened $open, Volume $newvol, Change $change";
49 $reply = "i couldn't get the quote for $stock. sorry. :(";
52 &::performStrictReply($reply);