Hello Monks.... I'm new here and though I've worked with Perl for a bit, still know very little.... I've inherited some code to use with an app and so can't really change that, but need to add some code to it to parse the data and pull out "a line" from the string. What I am trying to find is a way to pull out "SystemImage: flash:c3750-advipservicesk9-mz.122-46.SE.bin". (or whatever will come after SystemImage and before the end of the line. It'll always start with SystemImage. I've looked for a way to use \bSystemImage.*\b and store it in another variable, but I've yet to find a way to get that to work. It looks like \b is just used for getting a yes | no answer if something exists. I know it exists, I need to pull it out | get rid of the rest. I welcome any help!

use lib qw(blib lib); #use strict; use warnings; use Getopt::Long; use Pod::Usage; use Data::Dumper; use Opsware::NAS::Client; my($user,$pass,$host) = ('jon', 'doe', 'localhost'); my $help = 0; my $ip = '127.0.0.1'; my $nas = Opsware::NAS::Client->new(); my $res = $nas->login(-user => $user, -pass => $pass, -host => $host, +-nosession => '0'); my res = $nas->show_deviceinfo(ip => $ip)); #here's where the magic happens.... foreach my $tftp ($res->result()) { print "$tftp\n"; } $nas->logout(); Here's the output I get from the above code: DeviceInformation: Contact: NOC 111-222-3333 Hostname: bob Location: Creek Manufacturer: Cisco Model: WS-C3750G-48TS-S (C3750 series) OSVer: 12.2(46)SE Processor: WS-C3750G-48TS (PowerPC405) ROMVer: 12.2(25r)SEE4 SerialNumber: Z4CF,FOC688 ServiceTypes: Power SystemImage: flash:c3750-advipservicesk9-mz.122-46.SE.bin SystemMemory: 134209536

In reply to problems parsing data 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.