Ok, here's (hopefully) a more complete example:
Example strings to match:
confederation-as-router: 1 2345 atlanta1-cr1
confederation-as-router: 1 2345 atlanta1-cr2
confederation-as-router: 1 2345 atlanta1-cr3
confederation-as-router: 1 2345 atlanta1-cr4
confederation-as-router: 1 2345 atlanta1-cr5
confederation-as-router: 1 2345 atlanta1-cr6
confederation-as-router: 1 2345 atlanta1-sr1
open (FILE2, $file_2) or die "Couldn't open file: $!";
while (<FILE2>) {
if ($_ =~ s/^confederation-as-router\:\W+\d\W+\d+\W//) {
push(@file2, $_);
}
}
</CODE>
Currently, the regex will return:
atlanta1-cr1
atlanta1-cr2
atlanta1-cr3
atlanta1-cr4
atlanta1-cr5
atlanta1-cr6
atlanta1-sr1
Based upon the above example, I want it to ONLY return:
atlanta1-sr1
Is that clearer?
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.