in reply to regexp exclude a string
If you're on unix, you don't need the BEGIN{} block, and you'll need to use ^D instead ^Z. This assumes that any occurance of 'green red blue' are as shown in the examples, and not split across lines:
P:\test>perl -ln - text* BEGIN{ @ARGV = map glob, @ARGV} END{ print for sort keys %list } s[green red blue][]g; $list{ $ARGV }=1 if m[\b(green|red|blue)\b]; ^Z
If the three words could be split across lines, and your files are not huge, then you could use this instead:
P:\test>perl -0777 -ln - text* BEGIN{ @ARGV = map glob, @ARGV} END{ $\="\n"; print for sort keys %list } s[green\s+red\s+blue][]sg; $list{ $ARGV }=1 if m[\b(green|red|blue)\b]; ^Z
|
|---|