You have read the Exercise text first?
We can simply ignore blank lines:
File: rash-blanklines (changes only)
while (my $line = linenoise '> ').defined
{
next unless $line;
linenoiseHistoryAdd($line);
The full program is available as «rash-blanklines».