Hey all- been playing around with something here... I've got an array that is populated with data given by iptables. Specifically I'm just getting the data from one of the columns, but this is my problem. First off, I've seen this node:
How do I keep anything other than alphanumeric out of a variable? but would rather see something working from beginning to end.
The variable is an array, and i'm going through its elements, but the problem is that on top of the data I want (the ip addresses), it's also saving the return character, essentially it adds a '\n' on the end of every element. The question is based on how do I get rid of this bugger? It's making comparing the values against other things a big pain for me. The desired result would be converting '192.168.1.1\n' to '192.168.1.1'
Thanks again!
Edit by tye, turn http://... into a real link, [id://8384]
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.