Hello all. I am new here and hope this is a landing spot for junior folks like me who are in need of suggestions. If I'm in the wrong spot, quite sorry and thank you for your time. If so, perfect as I am having some trouble working with an array element. What is going on is we use an API that will let us connect to a Cisco device (router / switch) and issue a specified command and we get back the results. I use a push to populate the array. This works pretty well. Here's an example of the output of the array:

$VAR1 = [ [ 'show users | include idle 00:00:00', '*194 vty 0 spec idle 00:00:00 10.2 +34.171.75' ] ];

What I am after is the IP address at the end. In the case of the example, 10.234.171.75 Is there a way to work backwards to just get the IP? I'm finding ways to do basically this but for an element. In my case, I just have the one element. I've included the main code from my script, though don't think this is useful.

## ## Prepare for array to hold data from cmd ## This will hold the line sent (unfortunately - future work - fi +nd way to not capture this) ## This will hold the line returned, there should just be one lin +e. ## I am interested in IP, this IP could vary ## my @res = (); ## ## Note that the 'cmd()' method will return the results ## that were observed on the target device, following the ## given command. push @res, [$con->cmd("show users | include idle +00:00:00")]; ## print Dumper \@res;

I'm trying to get a foreach loop to work thru the array a space at a time, but this seems poor. Regards, Brian


In reply to working backwards in an array element? by CA_API

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.