perl : Remove empty lines from an array

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 to “perl : Remove empty lines from an array”

Comments are closed.