Hello,

I'm using the following code to parse out Firmware Versions from an OID, and would like some input on my regex. It's only capturing 5 of the 9.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array = (); while (<DATA>) { push @array, $1 if m[Version\s+(.*)\,.*]i; push @array, $1 if m[Version\:\s+(.*)\s+PROM\.*]; } print Dumper (@array); # Array should be: # 12.2(15)T8 # 2.2.0.1 # 9.0.0.2 # 6.3(7) # 5.0.0.3 # 2.1.2.1 # E5.8.0.3 # 1.00.00 S # 12.0(14) __DATA__ Cisco Internetwork Operating System Software IOS (tm) 7200 Software (C7200-JS-M), Version 12.2(15)T8, RELEASE SOFT +WARE (fc2) TAC Support: http://www.cisco.com/tac Copyright (c) 1986-2003 by cisco Systems, Inc. Compiled Tue 09-Sep-03 18:47 by pwade Cabletron Systems, Inc. Firmware Version: 2.2.0.1 PROM Version: prom-1 +.1.0.5 RS 3000 - Riverstone Networks, Inc. Firmware Version: 9.0.0.2 PROM Ver +sion: prom-2.0.1.3 Cisco Systems WS-C5000 Cisco Catalyst Operating System Software, Version 6.3(7) Copyright (c) 1995-2002 by Cisco Systems X-Pedition Security Router XSR-1805 version 5.0.0.3 Cabletron ELS100-24TXG SW:2.1.2.1 2521 Testing - Foo Company Firmware Version: E5.8.0.3 PROM Version: pr +om-P1.3.2.1 Cabletron ELS100-24TX SW: 1.00.00 S Cisco Internetwork Operating System Software IOS (tm) 4000 Software (C4000-IS-M), Version 12.0(14), RELEASE SOFTWAR +E (fc1) Copyright (c) 1986-2000 by cisco Systems, Inc. Compiled Wed 01-Nov-00 00:06 by linda

Any thoughts?


In reply to RegEx revision needed by Anonymous Monk

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.