Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2015-11-29 08:46 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (749 votes), past polls