I am currently slowly learning Perl. Previous languages have included fortran, C++, C, and VB, so therefore it isnt coming as that much of a hard move to me. The only problem I am having is taht I cannot for the life of me figure out how to extract a certain piece of information out of a line, depending on whether it passes certain criteria or not. The file is an irregular zone file, which I am trying to parse into a more acceptable format. An example of this file is:
EXAMPLE1 NS ns0.test.com
NS ns1.test.com
EXAMPLE2 NS ns0.test.com
NS ns1.test.com
EXAMPLE3 NS ns0.test.com
NS ns1.test.com
EXAMPLE4 NS ns0.test.com
NS ns1.test.com
The only piece of information I need extracted from the file is the domain name, but as the domain does not end in a prefix in the file ( not EXAMPLE1.COM, just EXAMPLE1 ), im finding it harder to extract just the domains, and skip the blank lines with only nameserver information in them. Any help that anyone can give me on this issue would be greatly appreciated. Thank you for your time, and Merry Xmas and a Happy New Year to all.
Adam.
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.