Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Remove newlines and join lines

by moxliukas (Curate)
on Aug 28, 2002 at 14:14 UTC ( #193464=note: print w/ replies, xml ) Need Help??


in reply to Remove newlines and join lines

Here is a way that I used to solve your problem (be careful about the number of newlines and alike. It is a very fragile approach)

#!/usr/bin/perl -w use strict; my $a = join '', <DATA>; $a =~ s/\n{2}(\d.\d+)/ $1/g; $a =~ s/\n{2}/\n/g; print $a; __DATA__ Alan 2.13 Mary 2.16

This prints:

Alan 2.13 Mary 2.16

I hope this is of any use.


Comment on Re: Remove newlines and join lines
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2015-07-06 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls