G'day dirtdog,

"The objective is to return the unique values in the {108: tag."

The data you've identified as being the unique values (8480963411 and 8481963413) are not unique: both occur twice. Unfortunately, that raises questions about whether: your spec is incorrect; the wrong input data was presented; the expected output was wrong; and so on.

This gets the expected values you've identified into a shell variable using a one-liner with the input data you've shown.

$ echo $PM_1225496 $ PM_1225496=`perl -Mstrict -Mwarnings -ne 'BEGIN { $/ = "{S:{CON:}}" +} while (/^.*?\{108\:(\w+)\}\}.*$/g) { print "$1\n" }'` {1:6392495900}{4:{177:1807300738}{451:1}{405:K22005}{108:8480963411}}{ +1:6392495900}{2:IVSN}{3:{108:8480963411}}{5:{MAC:00000000}{CHK:9F11}} +{S:{CON:}}${1:6392495903}{4:{177:1807300738}{451:1}{405:K22005}{108:8 +481963413}}{1:6392495903}{2:IVSN}{3:{108:8481963413}}{5:{MAC:00000000 +}{CHK:12846}}{S:{CON:}} $ echo $PM_1225496 8480963411 8481963413 $

I'll leave you to decide if that's what you wanted.

— Ken


In reply to Re: One Liner by kcott
in thread One Liner by dirtdog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.