Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
]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) ]a[3
--------------------- The tags are the flagged using ] and [ eg ]a[
What I then want to do is remove the tag from the line. Notice how with the ]b[ tag line there is more than one tagmy $a = '\[a\]'; my $b = '\[b\]'; open(HANDLE, "$dataFile") or warn "Error: Unable to open data file"; my @raw_data=<HANDLE>; foreach my $line (@raw_data) { if ($line =~ /$a/ ) { # Process } if ($line =~ /$b/) { # Process } } close HANDLE;
What would be a technique to remove the tags and sort into independant variables.eg ]b[LUCKY LAD]1[R72]c[(10)]d[57
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tag pattern matching
by graff (Chancellor) on Sep 06, 2005 at 03:36 UTC | |
|
Re: Tag pattern matching
by GrandFather (Saint) on Sep 06, 2005 at 03:10 UTC | |
|
Re: Tag pattern matching
by BrowserUk (Patriarch) on Sep 06, 2005 at 05:24 UTC | |
by Dizzley (Novice) on Sep 06, 2005 at 05:48 UTC | |
|
Re: Tag pattern matching
by albert (Monk) on Sep 06, 2005 at 05:08 UTC | |
|
Re: Tag pattern matching
by nedals (Deacon) on Sep 06, 2005 at 05:33 UTC | |
|
Re: Tag pattern matching
by Dizzley (Novice) on Sep 06, 2005 at 04:43 UTC | |
|
Re: Tag pattern matching
by Anonymous Monk on Sep 06, 2005 at 05:13 UTC |