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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.