Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Remove SOME new lines

by haukex (Archbishop)
on Jun 29, 2016 at 09:29 UTC ( [id://1166862]=note: print w/replies, xml ) Need Help??


in reply to Remove SOME new lines

Hi RenMcCourtey,

Is this what you're looking for?

$ cat in.txt AaX ObU UcU XdR ZeZ UfH UgU FhA OiG UjX UkZ UlZ xmT $ perl -pe 'chomp if /^U/' in.txt AaX ObU UcUXdR ZeZ UfHUgUFhA OiG UjXUkZUlZxmT

Update: Explanation: When using the -p switch without the -l switch (perlrun), each line read into $_ still contains the newline, which is normally output when the lines are printed back out. So the chomp just chops the newline off, and those lines are printed without the final newline.

Hope this helps,
-- Hauke D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found