How can I do reverse grep using Perl?

What is equivalent grep -vin Perl?

The code looks like this:

@files = reversegrep(/^[ ]+$/, @files);

I want to @fileshave a list of all file names that are not empty.

+3
source share
1 answer

You can use negation in an expression or block:

@files = grep !/^\s+$/, @files;

See perldoc grep .

+14
source

Source: https://habr.com/ru/post/1775382/


All Articles