Have expanded the variables further to fix more issues now.
#!/usr/local/bin/perl ## use strict; use warnings; use Data::Dumper; my @output = ( qq/Software\n/ .qq/ BIOS: version 3.6.0\n/ .qq/ kickstart: version 7.1(5)N1(1)\n/ .qq/ system: version 7.1(5)N1(1)\n/ .qq/ kickstart image file is: bootflash:\/\/\/n5000-uk9-kickstart +.7.1.5.N1.1.bin\n/ .qq/ system image file is: bootflash:\/\/\/n5000-uk9.7.1.5.N1. +1.bin\n/ .qq/Hardware\n/ .qq/ cisco Nexus 5548 Chassis ("O2 32X10GE\/Modular Universal Pla +tform Supervisor")\n/ .qq/ Intel(R) Xeon(R) CPU with 8253840 kB of memory.\n/ .qq/ Processor Board ID FOC163849D1\n/ .qq/ Device name: tpecasw01\n/ .qq/ bootflash: 2007040 kB\n/ .qq/Kernel uptime is 636 day(s), 1 hour(s), 34 minute(s), 49 secon +d(s)\n/ ); print "@output\n"; foreach (@output) { my %details; if (/^Hardware/mi) { $details{'Chassis'} = $1 if (/^\s*cisco Nexus (\S+) Chassi +s/mi); $details{'Main Memory'} = $1 if (/^\s*Intel.* with (\S+) kB of + memory/mi); $details{'Name'} = $1 if (/^\s*Device name: (\S+)/mi); $details{'Uptime'} = $1 if (/^\s*Kernel uptime is (.*?)\s*$/mi +); $details{'Version'} = $1 if (/^\s*system: .*version (\S+?)[,\s +]/mi); $details{'IOS File'} = $1 if (/^\s*system image file is:\s*"(. +*)"/mi); $details{Serial} = $1 if (/^\s*Processor board ID (\S+)/mi); $details{'ROM Version'} = $1 if (/^\s*BIOS: .*version (\S+?)[, +\s]/mi); # aka BIOS $details{'Boot Version'} = $1 if (/^\s*kickstart: .*version (\ +S+?)[,\s]/mi); # aka kickstarter $details{'Boot Flash'} = $1 if (/^\s*bootflash: (\S+)/mi); } print Dumper(\%details); }

All are working apart from $details('IOS File') is not populating/displaying. Any ideas? Result should be bootflash:///n5000-uk9.7.1.5.N1.1.bin

Value for 'IOS File' missing in results...

Software BIOS: version 3.6.0 kickstart: version 7.1(5)N1(1) system: version 7.1(5)N1(1) kickstart image file is: bootflash:///n5000-uk9-kickstart.7.1.5.N1.1 +.bin system image file is: bootflash:///n5000-uk9.7.1.5.N1.1.bin Hardware cisco Nexus 5548 Chassis ("O2 32X10GE/Modular Universal Platform Sup +ervisor") Intel(R) Xeon(R) CPU with 8253840 kB of memory. Processor Board ID FOC163849D1 Device name: tpecasw01 bootflash: 2007040 kB Kernel uptime is 636 day(s), 1 hour(s), 34 minute(s), 49 second(s) $VAR1 = { 'Uptime' => '636 day(s), 1 hour(s), 34 minute(s), 49 second( +s)', 'Serial' => 'FOC163849D1', 'Version' => '7.1(5)N1(1)', 'ROM Version' => '3.6.0', 'Main Memory' => '8253840', 'Name' => 'tpecasw01', 'Boot Version' => '7.1(5)N1(1)', 'Chassis' => '5548' };

In reply to Re: Parse variables from @output by Cisco_Dave
in thread Parse variables from @output by Cisco_Dave

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.