Looking at your data, it looks like you have a word "type" followed by a list of numbered definitions. I think I'd split each record apart at the numbers, discarding the numbers (since otherwise you'll get gaps in numbering anyway). Then I'd filter out the ones I don't want. It goes like this:
use strict; use warnings; while (<DATA>) { s/\s+$//; my ($type, @defs) = split /\(\d+\)/,$_; print "\n------ Word type: $type\n"; @defs = grep { ! m{\(arch\)} } @defs; print "\t$_\n" for @defs; } __DATA__ (n,vs) (1) look; glimpse; glance; (vs) (2) to glance; to glimpse; (3) +(arch) first meeting; (adv) (4) apparently; seemingly; (n-t,n-adv) (1) moment; a (short) time; a while; (2) former times; (3) + (arch) two-hour period;
When I run it, I get this:
$ perl 966375.pl ------ Word type: (n,vs) look; glimpse; glance; (vs) to glance; to glimpse; apparently; seemingly; ------ Word type: (n-t,n-adv) moment; a (short) time; a while; former times;
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Removing with regexps
by roboticus
in thread Removing with regexps
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |