in reply to Range Operator Mysteries
How about Yet Another Solution? I proposed a pop kind'o'solution, then:
With a little molding:undef $/; $_=<>; s/(\n\037.*?\n\* Menu.*?\n\037)//; $mymenu=$1;
The use of {10,} makes the code insensitive for the number of ='s. If you would use =+, you would also match ='s that were used in the text blocks. I leave the $2 in place, to facilitate the next match. The question mark ungreedies the wildmark. I haven't run the code, but it seems quite straightforward (aka likely without flaws).undef $/; $_=<>; while ( s/={10,}(\n.*?\n)(={10,}\n)/$2/s ) { push(@myblocks,$1); } print "I counted ".scalar(@myblocks)." blocks\n"; while ( $myblock=shift(@myblocks) ) { open( OUT, ">$myname" . $i++); print OUT $myblock; close OUT; }
Have fun,
Jeroen
I was dreaming of guitarnotes that would irritate an executive kind of guy (FZ)
Update: chipmunk pointed to some mistakes. Have been fixed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Range Operator Mysteries
by chipmunk (Parson) on Dec 01, 2000 at 20:25 UTC |