Hello Monks,
I have a small, yet significant issue. I have a rather large script that generates configuration files for network elements. The problem is that these elements have character limitations on several of the parameters, and currently I am manually manipulating output files to ensure we stay within the character limit. Obviously this makes for easy work errors.
One of my input files looks like this:
NT8
NT9
NT10
NT11
What I need perl to do is check each line in the file, and if it is three characters, add a '_' at the end, but omit that underscore if it is 4 characters, so it would look like this:
NT8_
NT9_
NT10
NT11
As usual, any and all help is appreciated.
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.