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;
24 &::getURL( 'http://quote.yahoo.com/d/quotes.csv'
25 . "?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) {
34 # get rid of the quotes
38 $ticker, $recent, $date, $time, $change,
39 $open, $high, $low, $volume
40 ) = split( ',', $result );
43 # "+ 0" removes trailing cr/lf/etc.
44 my $newvol = commify( $volume + 0 );
46 $reply .= ' ;; ' if $reply;
48 "$ticker: $recent ($high/$low), $date $time, "
49 . "Opened $open, Volume $newvol, Change $change";
53 $reply = "i couldn't get the quote for $stock. sorry. :(";
56 &::performStrictReply($reply);
61 # vim:ts=4:sw=4:expandtab:tw=80