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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |