That's all quite lovely - I'd like a puppy. While there are plenty of people here who are happy to help, the tone I get from your message is that you want us to do your work for you. I assume that this is unintentional, but please be cognizant of how you ask questions in the future. See How do I post a question effectively?.

Also note the material you posted is far more complicated than it need be - you are using 7 different modules and have strict commented out when you really just need know how to process your sample input. You also can include multiple instances of <code> tags in one post, and this can really aid in clarity.

I don't understand what you mean by case 3 (an example is worth 1,000 words) but everything else you ask can be done in a fairly straight-forward fashion using regular expressions and Loop Control. I've crafted up some simple treatments, where I've assumed $res->result() returns a scalar string as indicated by your Data::Dumper output. If anything is unclear, I'll be happy to clarify:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $data = do{local $/; <DATA>}; print Dumper([$data]), "\n\n"; my $result_1; for (split /(?<=\n)/, $data) { next unless /^\Qsnmp-server host\E/; $result_1 .= $_; } print "---Result 1---\n$result_1\n\n"; my $result_2; for (split /(?<=\n)/, $data) { next unless /^\Qsnmp-server\E/; s/^((?:\S+\s+){3})\S+/${1}Bob/; $result_2 .= $_; } print "---Result 2---\n$result_2\n\n"; __DATA__ snmp-server host 10.234.171.45 admin snmp-server host 10.234.171.46 admin snmp-server host 10.234.171.51 admin frame-relay config snmp snmp-server host 10.234.171.75 admin snmp-server host 10.234.171.51 publ frame-relay config snmp snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.46 admin snmp-server host 10.234.171.51 admin frame-relay config snmp snmp-server host 10.234.171.75 admin snmp-server host 10.234.171.51 publ frame-relay config snmp snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.51 admin frame-relay config snmp snmp-server host 10.234.171.75 admin snmp-server host 10.234.171.51 publ frame-relay config snmp snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.75 admin snmp-server host 10.234.171.51 publ frame-relay config snmp snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.51 publ frame-relay config snmp snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.54 publ frame-relay config snmp snmp-server host 10.234.171.59 publ !snmp-server host 10.234.171.59 publ !

In reply to Re: pulling more data from an array by kennethk
in thread pulling more data from an array by zonevbkr

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.