Rather than just the textual description you included above, it is generally much better to include a small sample of your actual input wrapped in code tags. Note that your post has been misformatted as a result. See
Writeup Formatting Tips. Also, please provide sample output, as I have a great deal of trouble following your spec. See
How do I post a question effectively?.
I note that your posted code has several basic syntactic issues. Are you learning Perl from a book, or are you attempting to modify someone else's script? Do you have any background in programming in general? These issues include using a capitalized AND (vs. and, Perl is case sensitive), Modifiers on your regular expressions that are inappropriate for what you are trying to do, and a wholly incorrect block structure. Telling us where you are will let us better guide your development as a programmer and point you to more useful resources.
I am loathe to leave this node without a concrete bit of suggested code, but I am at a loss for how to even modify the posted code to "work".
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.