Lo,
I have a snippet of fixed code, ie I can't change it. All that I have control over is the regex that is passed to it..
open FH, "< $file";
while (<FH>) {
# for each regex
for my $re ( keys %{ $compiled->{'rx'} } ) {
$compiled->{'rx'}{$re}++ if /$re/;
}
}
close FH;
I have some DOS (ie each line ends in \r\n) files that are look like (this is run on linux)
foo
bar
"99","END"
or
"99","END"
ie all files contain "99","END" but some contain other lines before it.
My problem is that I need to positively match the files containing _only_ the "99","END"
ie in the example files above, I have a regex that would match "foo", this would find the first file, however, what regex would find the second file? One of END wouldn't work because that would find the foo file.
The only idea I have is to embed perl in a regex and somehow test that if we have END and are on the first iteration of the while, it matches.
Any other ideas appreciated...
John
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.