Hi there. I was trying to run your script and found that the output files were empty. I tracked down the problem to Line 42:

push(@lin, $2) if $_ =~ /(Volume Leaders;US;NASDAQ;AMEX;NYSE;)(Sym +bol;Name.*)/g;

You need to get rid of the " +" in Sym +bol.

edit: there is another on (although benign) in line 54:

$vf =~ s/Symbol\|Name\|Last Trade\|Change\|Volume\|Related Info\|/SYMB +OL\|NAME\|LAST TRADE\|CHANGE\|VOLUME\|RELATED INFO\n/g;

edit2: and another on line 57. This one screws up your regex:

$vf =~ s/\|(\d|\d\d|\d\d\d)\.(\d|\d\d|\d\d\d)\|(\d|\d\d|\d\d\d)\:(\d|\ + +d\d|\d\d\d)/\|$1\.$2 $3\:$4/g; }

To avoid these, you want to be careful to click the 'Download' link before copying code from PM, since lines that get wrapped get " +" added to the break.

Regarding that regex I pointed out, I'd like to recommend an easier to write/read/maintain way of doing this:

$vf =~ s/\|(\d{1,3})\.(\d{1,3})\|(\d{1,3})\:(\d{1,3})/\|$1\.$2 $3\:$4/g;

However, I suspect that you meant to use the following since $3 and $4 are matching a time:

$vf =~ s/\|(\d{1,3})\.(\d{1,3})\|(\d{1,2})\:(\d{2})/\|$1\.$2 $3\:$4/g;

Since you are matching 1, 2, or 3 digits, instead of writing out each variation, you can specify a range using the curlies. Check out QUANTIFIERS for more info.


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.