perlnewb has asked for the wisdom of the Perl Monks concerning the following question:
And this script is run by the user rather frequently (it does other things too). There's another script that adds " sometext :"to the end messages.txt file. Here's the problem. When i manually edit the messages.txt file and add in more than 20 elements, it cuts it fine. but when my script adds more than 20 elements, the messages.txt file doesn't get cut. Any ideas? I'm utterly flabbergasted#grap the string from the file local $/=undef; open FILE, "messages.txt" or die "Couldn't open file: MESSAGES $!"; $string = <FILE>; close FILE; $string =~ tr/\n//d; #remove the last twenty lines: split it into an array by : @a = split(/:/,$string); splice (@a,0,-20); $stringb = join(':',@a); #fix up da file, so it dont have no more than 20 lines, foo! open MS, "> messages.txt"; print MS "$stringb"; close MS;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: slighly newbish question
by Zaxo (Archbishop) on Nov 17, 2002 at 05:35 UTC | |
|
Re: slighly newbish question
by pg (Canon) on Nov 17, 2002 at 05:30 UTC | |
by Anonymous Monk on Nov 17, 2002 at 14:32 UTC | |
by pg (Canon) on Nov 17, 2002 at 17:25 UTC | |
|
Re: slighly newbish question
by UnderMine (Friar) on Nov 17, 2002 at 13:41 UTC |