Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Perl modifying output of an array to remove blank lines

by hippo (Bishop)
on Oct 08, 2015 at 23:37 UTC ( [id://1144248]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl modifying output of an array to remove blank lines
in thread Perl modifying output of an array to remove blank lines

I humbly refer you to my previous reply which solves namelessjoe's problem. It works because the @goodlines array is empty on those occasions where the blank lines are output.

In short, there's no point trying to remove some entries from the array which are themselves empty or just whitespace because there are no entries in the array. The thread title is a bit misleading in that respect. I initially started down the route which you and stevieb took, but a quick test determined that the output would not match what was reported in the original node. Hence the conclusion/supposition that the "bad" lines were ones where the array was entirely empty.

Hope this helps and that it avoids anybody spending more time on blind alleys.

Replies are listed 'Best First'.
Re^5: Perl modifying output of an array to remove blank lines
by stevieb (Canon) on Oct 08, 2015 at 23:58 UTC

    Nice observation. Usually 'good post' type posts aren't presented here, but you had a good eye to suit the OP with what they were specifically asking.

    Short-circuiting definitely works better than iteration and removal (in the specific case presented).

    -stevieb

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1144248]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found