Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Remove newlines and join lines

by moxliukas (Curate)
on Aug 28, 2002 at 14:14 UTC ( [id://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.

Log In?
Username:
Password:

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

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

    No recent polls found