What is in your @Goodlines array? The code posted by stevieb seems to work exactly as advertised:
c:\@Work\Perl>perl -wMstrict -MData::Dump -le
"my @lines = ('', ' ', ' ', 'x', ' x', 'x ', ' x ', ' x ',);
;;
my @no_empties = grep { $_ !~ /^(?:\s+|)$/ } @lines;
;;
dd \@no_empties;
"
["x", " x", "x ", " x ", " x "]
Can you put something into the
@lines array that doesn't come out as you want?
Incidentally, I would prefer an inverse approach to the regex: a non-blank line is one that has at least one non-blank (i.e., non-whitespace, or \S) character in it:
c:\@Work\Perl>perl -wMstrict -MData::Dump -le
"my @lines = ('', ' ', ' ', 'x', ' x', 'x ', ' x ', ' x ',);
;;
my @no_empties = grep m{\S}xms, @lines;
;;
dd \@no_empties;
"
["x", " x", "x ", " x ", " x "]
Give a man a fish: <%-{-{-{-<