getquote.pl 416 B

1234567891011121314151617181920
  1. #!/usr/bin/env perl
  2. $timeout = 60;
  3. use Finance::Quote;
  4. use POSIX qw(strftime localtime time);
  5. $q = Finance::Quote->new;
  6. $q->timeout($timeout);
  7. $q->require_labels(qw/price/);
  8. %quotes = $q->fetch("nasdaq", $ARGV[0]);
  9. if ($quotes{$ARGV[0], "price"}) {
  10. print strftime('%Y/%m/%d %H:%M:%S', localtime(time()));
  11. print " ", $ARGV[0], " ";
  12. print "\$", $quotes{$ARGV[0], "price"}, "\n";
  13. } else {
  14. exit 1;
  15. }