Let's say you have an array of data that contains empty lines, like this.
Hello
World
How
are
you
The following markup can be used to remove the empty lines from the array. The \S regular expression means "anything except for a whitespace". It may also be noteworthy that \s means "whitespace", thus \S is the opposite of \s.
@array = grep /\S/, @array;
Which will result in the array having no empty lines, like this.
Hello
World
How
are
you
Looping through array
If you are looping through the array, something like this should get the job done.
foreach my $line (@array) {
$line =~ s|^\s*$||g;
}