Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found