Categories
Perl

perl : Remove empty lines from an array

Using grep and pattern matching, empty lines can be removed from an array in perl.

Using grep the empty lines can be removed from an array in perl. Here is how.

### Remove any empty lines
@dataArray = grep(/S/, @dataArray);


S does the pattern matching that if everything on that line is a space.

 

2 replies on “perl : Remove empty lines from an array”

Comments are closed.