Enlightened ones,
I'm trying to separate strings into 7 elements. The problem is if an element contains a space or is blank, it is surrounded by {}, so I can't split on spaces. There is no uniformity to which elements are enclosed by brackets.
Here are 3 lines of actual data as samples:
aotone 1 {FixServer AOT1} FixServer {-F FxAOT1} {} 1
FxACH 2 achfxsvr FixServer {-F FxACH} routex 0
ESIS 2 {ESISAdministrative Server} java -Did=esisadmin routex 0
My thought was to replace any spaces within brackets with dummy characters #%, split on spaces, discard brackets, then replace #% back with spaces. That would be a lot of work, and I'm sure there's a better way, I'm just too much of a noob to know what that is.
Any help would be appreciated.
Thanks!
2005-09-13 Retitled by Arunbear, as per Monastery guidelines
Original title: 'There's gotta be a better way...'
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.