hi.
What i'm trying to do is keep a file of usernames, with numbers next to them:
-----------------
ben0
joe1
sophie2
etc...
----------------
when a user is added, the array is sorted using an inserytion sort, a number is assigned to the new entry, then the entire array is renumbered.
--------code-----------
chomp($username);
$username .= $pointer;
$username .= "\n";
push(@array, $username);
push(@array, @temp);
chomp(@array);
$inc = 0;
foreach $id (@array) {
$L = length($id);
$temp = substr($id, 0, $L - 1);
$id = "$temp$inc\n";
$inc++;
}
-------------------------
however, the file keeps getting corrupted ( as in, numbers on new lines, increasing amounts of numbers, etc...)
---------output ("C:/users.dat"
--------
be0
1
joe2
john
3
sophie4
swanny5
zebedy6
----------------------------------------
so if anyone knows why this isn't working...a stray newline character, bad or non existent chomp etc. I'd be really grateful for all suggestions!!
thankyou all
JoZeF
we are all of us living in the gutter.
But some of us are looking at the stars.
What i'm trying to do is keep a file of usernames, with numbers next to them:
-----------------
ben0
joe1
sophie2
etc...
----------------
when a user is added, the array is sorted using an inserytion sort, a number is assigned to the new entry, then the entire array is renumbered.
--------code-----------
chomp($username);
$username .= $pointer;
$username .= "\n";
push(@array, $username);
push(@array, @temp);
chomp(@array);
$inc = 0;
foreach $id (@array) {
$L = length($id);
$temp = substr($id, 0, $L - 1);
$id = "$temp$inc\n";
$inc++;
}
-------------------------
however, the file keeps getting corrupted ( as in, numbers on new lines, increasing amounts of numbers, etc...)
---------output ("C:/users.dat"
be0
1
joe2
john
3
sophie4
swanny5
zebedy6
----------------------------------------
so if anyone knows why this isn't working...a stray newline character, bad or non existent chomp etc. I'd be really grateful for all suggestions!!
thankyou all
JoZeF
we are all of us living in the gutter.
But some of us are looking at the stars.