Posted by Frank Hale on 1999-03-18
>
> I would post my code but it will only serve to confuse the question
> more. Trust me the code is sloppy and downright unreadable at this point
> in the game.
>
Okay here is the code I have so far I shortened it up a bit to
illustrate my problem. I am way out in left field and can't seem to
understand the way I need to write this algorithm
# Iterate through each element in the DELETE_INDEX hash.
foreach $DI (keys %DELETE_INDEX)
{
# If the element's data equals 1 then we need to delete this record.
if ($userdata{$DELETE_INDEX{$DI}} == 1)
{
# For each line in the file do something with that data.
foreach $line (@headers)
{
# If the line equals i: then we have the index
if (substr($line,0,2) eq "i:") {
# store this records index in $index
$index = substr($line,2);
# If this is true we keep the record.
if (not $index == $DI) {
print "<br>index = ".$index."<br>";
}
}
}
}
}
Sample output on 4 records goes like this. If I delete records 1 and 2 I
get the following output
index = 2
index = 3
index = 4
index = 1
index = 3
index = 4
This describes how my algorithm writes to the file multiple times but it
did delete the records I wanted but it did it over multiple iterations
continuing to write back to the file screwing it up.
As you can see I am pretty lost on this. If someone could offer any
psuedo-code for the type of algorithm I need I would really appreciate
it. Thanks.
--
From: Frank Hale
Email: frankhale@xxxxxxxx.xxx.xxx
ICQ: 7205161
Website: http://www.franksstuff.com
Previous post | Next post | Timeline | Home