Hi all,
I was hoping some of you could cast your experienced eyes over this.

I'm trying to process some text as shown below:

graphics 0 1 graph3 CLAIMED INTERFACE Graphics ext_bus 0 2/0/1 c720 CLAIMED INTERFACE Built-in + SCSI disk 0 2/0/1.0.0 sdisk CLAIMED DEVICE HP +C2247M1 /dev/dsk/c0t0d0 /dev/rdsk/c0t0d0 disk 1 2/0/1.2.0 sdisk CLAIMED DEVICE TOSHIBA +CD-ROM XM-3401TA /dev/dsk/c0t2d0 /dev/rdsk/c0t2d0 disk 2 2/0/1.6.0 sdisk CLAIMED DEVICE SEAGATE +ST31200N /dev/dsk/c0t6d0 /dev/rdsk/c0t6d0 ctl 0 2/0/1.7.0 sctl CLAIMED DEVICE Initiato +r /dev/rscsi/c0t7d0 lan 0 2/0/2 lan2 CLAIMED INTERFACE Built-in + LAN /dev/diag/lan0 /dev/ether0 tty 0 2/0/4 asio0 CLAIMED INTERFACE Built-in + RS-232C /dev/diag/mux0 /dev/mux0 /dev/tty0p0 ext_bus 1 2/0/6 CentIf CLAIMED INTERFACE Built-in + Parallel Interface /dev/c1t0d0_lp audio 0 2/0/8 audio CLAIMED INTERFACE Built-in + Audio /dev/audio /dev/audioEL_0 /dev/audioLL +_0 /dev/audioBA /dev/audioEU /dev/audioLU + /dev/audioBA_0 /dev/audioEU_0 /dev/audioLU +_0 /dev/audioBL /dev/audioIA /dev/audioNA + /dev/audioBL_0 /dev/audioIA_0 /dev/audioNA +_0 /dev/audioBU /dev/audioIL /dev/audioNL + /dev/audioBU_0 /dev/audioIL_0 /dev/audioNL +_0 /dev/audioCtl /dev/audioIU /dev/audioNU + /dev/audioCtl_0 /dev/audioIU_0 /dev/audioNU +_0 /dev/audioEA /dev/audioLA /dev/audio_0 + /dev/audioEA_0 /dev/audioLA_0 /dev/audioEL /dev/audioLL pc 0 2/0/10 fdc CLAIMED INTERFACE Built-in + Floppy Drive ps2 0 2/0/11 ps2 CLAIMED

(some of you may recognise this as an hpux ioscan output)
and I have the following chunk of code:

 ($header,@devices) = m/(Class.+\n=+\n)(^\w.+\n(?:\s+.+\n)*)/mg

What I'm trying to do is split out each seperate device and its associated text into an array

On my journey to enlightenment, I've started to venture beyond the world of very simple regexps into slightly more involved versions, and reading through perlmonks I've seen mention of greedy regexps and I think I understand why they're a bad thing

I suspect that this regexp is a prime example of such a beast, but I was hoping for the views of more enlightened members of PM and any pointers on how the regexp could be improved if necessary

Edited: ~Tue Oct 1 16:07:42 2002 (GMT) by footpad: Replaced <pre> tags with <code> tags, per Consideration


In reply to A query on greedy regexps by sch

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.