为什么这种排除不适用于长句?

Why this exclusion not working for long sentences?

命令

perl -ne 'print unless /.[240,]/' input.txt > output.txt

其中包括一些长度超过 240 个字母的句子。为什么?

示例数据

Development of World Funny Society program on young people who are working hard for the sport and social life such that they have time to go pizzeria every now and then and do some fun, programming and having great breakfast:| World scenario of free time programs are often too long such that this star probably makes the program upset (*)|Again a very long option which is not probably the reason which makes this program upset|good shorter option which is ok but nice to write here coffee morning messages|c last option is always good one because you know that you can soon stop 1

示例数据 2

Indications of this program depends on many things and I like much more this than Lorem ipsum which is too generic and takes too much time to open:|short option just in case|little longer option so good to have it here too|shorter which is better too but how much is the question|shortest is not the least|longer one once again but not too long 1

您使用了错误的语法:[] 用于匹配字符 class,而此处您试图匹配 . 的多次出现,这可以使用 {}:

来完成
perl -ne 'print unless /.{240,}/' input.txt > output.txt

此外,正如 salva 在评论中所建议的,模式可以缩短为 .{240}:

perl -ne 'print unless /.{240}/' input.txt > output.txt