Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, If anyone has a elegant solution for this, please share it with me..

I am reading result a file and have already found the lines I wish to join but...this is not working....

I have names like Mary,Alan,David and I am searching for those from file. Once I have found it, I just would like to remove empty lines and attach the next written line after the word.

Original file looked like

Alan 2.13 Mary 2.16 And the new file would be: Alan 2.13 Mary 2.16
I cant seem to get that end of line off and join those lines...

Small but irritating problems cause I dont know how.

open (ROWS, "style.txt") || die "File not found"; while (defined ($rivi = <ROWS>)) { if($rivi =~ /^$names[$i]/) { chomp $rivi; $rivi=~tr/\n\n//; $rivi=~s/\n\n//; $rivi=~tr/0xb6//; $rivi=~tr/0xb6//; . . . . my $text=$text.$rivi; open (E,">>style1.txt"); print E $text; close E; }
BR Hewarn

In reply to Remove newlines and join lines by hewarn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found