I don't believe your code is working quite how you think - you're iterating over
TMPFILE, then slurping it's contents with the
join (which also means you're missing the first line) and then performing a match on that string, repeating the same procedure, and then performing another match on the same string. A simple reduction might look like this (explained below)
open(TMPFILE, "page.html") or die("Can't open page.html: $!")
my($data, $data2);
{
local $/;
local $_ = <TMPFILE>;
($data) = /'(\d{3})wordONE/;
($data2) = /(\d{3})wordTWO/;
}
close(TMPFILE);
That slurps
TMPFILE (by
undefining
$/) into a
localised
$_ then performs two matches on
$_ saving the contents captured in the parentheses into the variables
$data and
$data2 respectively. This should produce the same (and more reliable) result of the code you demonstrated.
HTH
_________
broquaint
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.