Hi, I'm capturing the string using (.\d+\.\d+) with the . matching the ~ since that is only present if the values are 0.00. If they were 51.11 for example, there would be no ~ but would still match as there's spaces after Util before the actual digit. Might be a better way to do that?

My values are just printed to screen and are held in $text:

my $text = $host->cmd("monitor lag $lag_traffic interval 3 repeat 3 ra +te | match Totals post-lines 1");

$lag_traffic is just derived from another input that is held in @lag_id:

my $lags = $host->cmd("show lag description"); my @lag_id = ( $lags =~ m/(\d+)\Se\S/g );

For a guess, you're pretty spot on. Essentially what I want is to have the following displayed:

LAG ID 200:
1 - Input - x Output - x
2 - Input - x Output - x
3 - Input - x Output - x
LAG ID 199:
1 - Input - x Output - x
2 - Input - x Output - x
3 - Input - x Output - x

Your recommendation solves why it was just counting the contents, so thank you. Given I know the first value in the text is always input and the second is always output, would it be easier to split them up before or after putting them in the key?


In reply to Re^2: Store and print multiple strings by bartrad
in thread Store and print multiple strings by bartrad

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.