Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含文本文件的数组......那么如何使用 perl 找到只包含一个单词的数组元素?
假设文件内容存储在@lines
@lines
my @words = grep /^\S+$/, @lines;
注意:chomp @lines;在进一步处理之前不要忘记。
chomp @lines;