Hi Monks
Hope you can help me. I have the following code which takes in results and posts them to a storage file for later retreval.
# update values with this weeks results and scores
for (my $j = 0; $j <= $#teams; $j++) {
print "\nDo You have results for $teams[$j] (y\\n)?\n";
$answer=<STDIN>;
chomp($answer);
if ($answer =~ /[Yy](es)*/) {
$team_number = $j*5;
$Values[$team_number]=$teams[$j];
print "$j\t\t$Values[$team_number]\n";
print "\nHome Result ((W D or L) _ if its an away game):\n
+";
$home_result=<STDIN>;
chomp($home_result);
$home_result=~s/\s+$//g;
$Values[$team_number+1]=~s/($Values[$team_number+1
+])/$1$home_result/g;
exit 1;
}
# update storage file
open(SNMPFILE,"+< store.txt");
for ($ae = 0; $ae <= $#Values; $ae++) {
print SNMPFILE "$Values[$ae] ";
}
close(SNMPFILE);
The problem is when I am typing in a result and I get it wrong and backspace over it and enter the correct value the file gets updated with the old value as well as the new value
This is what appeared in the file when I typed in W then backspaced and printed D : WD
Is there a way to rectify this?
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.