OK, since I'm not entirely sure what you need, perhaps you could elaborate. To start, this is the first few lines from one of the output files:

SYMBOL|NAME|LAST TRADE|CHANGE|VOLUME|RELATED INFO BAC|Bank of America Corporation Com|7.82 4:00PM EDT|0.24 (2.98%)|120,1 +61,969|Chart, Profile, More JPM|JP Morgan Chase & Co. Common St|34.38 4:02PM EDT|1.50 (4.18%)|58,5 +29,307|Chart, Profile, More SIRI|Sirius XM Radio Inc.|2.09 4:00PM EDT|0.05 (2.45%)|52,421,104|Char +t, Profile, More

Are you wanting to change "Chart, Profile, More" into "Chart, Profile, More"? If so, since you are only collecting the text and not links from the yahoo pages, your best bet is to harvest the symbols (e.g., BAC) from what you have and stick them into Yahoo's link template (e.g. http://finance.yahoo.com/q/bc?s=INSERT_SYMBOL_HERE for Charts). Assuming this is what you are trying to do, I wrote to following as a proof-of-concept and used it to replace print US $lin[1];:

for my $lin_line ( split (/\n/, $lin[1]) ) { my ( $symbol ) = $lin_line =~ m/(\w*)|/; next if $symbol eq "SYMBOL"; $lin_line =~ s|(Chart)|$1: http://finance.yahoo.com/q/bc?s=$symbol +|; } continue { print US $lin_line, "\n"; }

The output looks like:

SYMBOL|NAME|LAST TRADE|CHANGE|VOLUME|RELATED INFO BAC|Bank of America Corporation Com|7.82|Jul 5|0.24 (2.98%)|120,161,96 +9|Chart: http://finance.yahoo.com/q/bc?s=BAC, Profile, More JPM|JP Morgan Chase & Co. Common St|34.38|Jul 5|1.50 (4.18%)|58,529,30 +7|Chart: http://finance.yahoo.com/q/bc?s=JPM, Profile, More SIRI|Sirius XM Radio Inc.|2.09|Jul 5|0.05 (2.45%)|52,421,104|Chart: ht +tp://finance.yahoo.com/q/bc?s=SIRI, Profile, More

If this is what you are going for, you should elaborate on so that it reports links for 'Profile' and 'More' for all your output files.

One other thing... You are saving your files as csv, but the data you output is not comma-delimited (unless you only want 3 columns).


In reply to Re: extracting from web and adding to csv file with their links by frozenwithjoy
in thread extracting from web and adding to csv file with their links by programmer.perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.