#!/iw/perl/current/bin/perl # # file: gen-ticker-map.pl # desc: generate various output formats of stock ticker data # eval 'exec /iw/perl/current/bin/perl -s $0 ${1+"$@"}' if 0; # we want perl 5.00x or later require 5.004; # who am i? ($prog = $0) =~ s#.*/##; use Getopt::Std; # process command line options, if any getopts('D:PT'); # generate perl data structure of ticker data? my($do_perl) = defined($opt_P); # generate Tcl data structure of ticker data? my($do_tcl) = defined($opt_T); if (! $do_perl && ! $do_tcl) { print usage(); exit 1; } # slurp in the ticker data my(%ticker_map) = (); while(<>) { chomp; my($ticker, $uri, $company, $cik) = split(/\|/); # ignore ftp://ftp.sec.gov/... URIs since they are links to skulked documents # and not to the companies $uri = "" if ($uri =~ m@^ftp://ftp.sec.gov/@); $ticker_map{$ticker} = {uri => $uri, company => $company, cik => $cik}; } if ($do_perl) { # generate perl library file print < {", "cik => '", $cik, "', company => '", $company, "', uri => '", $uri, "'", "},\n"; } print ");\n"; print <