Welcome Guest. | Log In| Register | Membership Benefits
#!/usr/local/bin/perl use URI::URL; use URI::Escape; use LWP::UserAgent; use Date::Format; use Date::Parse; use Date::Manip; require "/techweb/pubs/www/staging/scripts/ad_client.pl"; $symbol_file = "/techweb/pubs/www/production/iw/cgi-bin/iw1001.csv"; read_symbol_file($symbol_file); $remote_page = "http://fast.quote.com/fq/cmpmedia/group?moe=Groups&group=iw100"; my $table_string = parse_page(read_remote_page($remote_page)); print_results($table_string); exit; ####### sub read_remote_page($){ my ($url) = @_; my $ua = new LWP::UserAgent; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); my $server_response = $response->as_string; my $page = $response->content; return $page; } #### sub parse_page($){ my ($html_string) = @_; $head_string = ""; ($head, $html_remain) = split(/$head_string/, $html_string); my $html_table = ""; $html_table .= "\n"; @lines = split(/
/, $html_remain); foreach $i (@lines){ ($symbol, $company_name, $current_price, $change, $the_date, $the_time, $volume) = split (/\t/, $i); $symbol =~ s/\s//g; $sym_arr{$symbol} =~ s/\s//g; if($sym_arr{$symbol}){ $company_name = "$company_name"; } $html_table .= "\n"; } # symbol, company name, current price, change, date, time, volume $html_table .= "
SymbolCompany NameLastChangeVolume
$symbol$company_name$current_price$change$volume
\n"; return $html_table; } #### sub read_symbol_file { my ($file) = @_; open IN, "$file" || die "Cannot open $file\n"; while(){ my $line = $_; ($name, $blank, $id) = split(/\,/, $line); ($a, $sym_string) = split(/\(/, $name); ($symbol, $b) = split(/\)/, $sym_string); $sym_arr{$symbol}=$id; } close(IN); } #### sub print_results($){ my ($param_1) = @_; $Replace{stock_table} = $param_1; print "Content-type: text/html\n\n"; $Replace{ad1} = view_ad(position=>'76', pub=>'IWK', page=>'Left'); ($string1, $string2) = split(/WIDTH=/, $ad); ($width, $rest) = split(/ /, $string2); if($width < 300){ $Replace{ad2} = view_ad(position=>'77', pub=>'IWK', page=>'Left'); } else { $Replace{ad2}=""; } $Replace{ad3} = view_ad(position=>'IWKNavBar', pub=>'IWK', page=>'Left'); $Replace{ad4} = view_ad(position=>'resources125x65', pub=>'CMP', page=>'Side'); $Replace{ad5} = view_ad(position=>'iwkpromo', pub=>'IWK', page=>'Bottom'); $Replace{date_string} = time2str("%B %e, %Y",time()); file_spew("finchart.tmpl"); return 1; } #### sub file_spew { foreach $file (@_){ open(F, $file) || die "cannot open filename: $!"; while(){ while( ($cgpr_VARNAME) = m/<\$([A-Z_a-z0-9]+)>/ ){ s/<\$$cgpr_VARNAME>/$Replace{$cgpr_VARNAME}/g; } print; } close(F); } return 1; } #### sub string_proper { my($input)=@_; my(@words,$word); my $result = ""; $input=~ tr/A-Z/a-z/; @words=split(/ /,$input); foreach $word (@words){ substr($word,0,1) =~ tr/a-z/A-Z/; $result .= $word." "; } return $result; } #####
CAREER CENTER
Ready to take that job and shove it?



TechCareers

SEARCH
Function:

Keyword(s):

State:
SPONSOR
RECENT JOB POSTINGS
CAREER NEWS
Go beyond Google and get vertical. These specialized search sites will help you find the business information you need -- fast.

Ari Balogh was named to the post of chief technology officer as the companys for a "realignment" of employees.



Specialty Resources

Featured Microsite