Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 chanting in the Monastery: (3)
As of 2014-07-29 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls