I'm guessing you wanted to split the data on more than just 'a' and 'b'.

This will split on each of the tags, 'a'..'m', and put each bit of text into seperate elements of an AoA (array of arrays)

use strict; use Data::Dumper; ## Seperate each element of each group into an AoA my @AoA = (); my $i = 0; while (<DATA>) { chomp; ## split each line so each 'element' is processed as seperate line my @lines = split(']',$_); for (@lines) { if ($_) { ## Skip the blank lines created bt 'split' my $line = $_; $line =~ s/\w\[//; ## Get rid of the 'x[' push @{$AoA[$i]},$line; } } $i++ if (@lines[1] =~ /m\[/); } print Dumper(\@AoA); exit; __DATA__ ]a[1 ]b[FORTUNE BAY]1[R74]c[(9)]d[58 ]e[b g 9 Little Brown Jug-Gemfly (by Golden Elder (GB))]f[(BLINKERS) ]g[A W & Mrs P I Reynolds, T A Robinson, D J & Mrs V G Stuart & A R Wa +ghorn ]h[Gay Stuart, Riverton ]i[Emerald green, navy blue braces & diamond armbands, emerald green c +ap ]j[04640]w[CANT 13 Aug H Rating 76 1600m 11 of 16 Tailend inr,btld clo +ser inr T C Newton 58 (6) 15/15 Wnr: BRIGHTON PIER (AUS) 1:42.69 13.8 +L ]k[ :(46-2-7-6-6-$21145) ]m[ F(0-0-0) G(17-1-5) D(7-0-1) S(15-1-6) H(7-0-1) C(1-0-0) Dst(2-0-0) ]a[2 ]b[LUCKY LAD]1[R72]c[(10)]d[57 ]e[ch g 6 Shinko King (IRE)-Argyll Dazzler (by Tarrago (ITY))]f[(BLINK +ERS) ]g[D H F Green ]h[Kevin Hughes, Riccarton Park ]i[Emerald green & light blue diagonal stripes, striped sleeves & cap ]j[X3333]w[CANT 10 Aug H Rating 76 1800m 3 of 15 Trld ldr,2nd tn,fght +mid N G Harris 57 (4) 1/1 Wnr: SHRKAN 2:01.69 4.5L ]k[ :(28-1-4-7-2-$12688) ]m[ F(0-0-0) G(13-0-4) D(7-0-3) S(6-1-3) H(2-0-1) C(0-0-0) Dst(3-0-2)

In reply to Re: Tag pattern matching by nedals
in thread Tag pattern matching 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.