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
-
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.
|