Gossamer Forum
Home : Products : DBMan : Customization :

Question about archive

Quote Reply
Question about archive
Hi! I was wondering where to insert this line that reference to a subrountine I created. that subroutine would generate a random number. I need this random nunber to be generated for each record that is archived. I tried to insert it where it is shown in red but it caused the subsequent archived records to have the randowm number appended to the newly generated random number. Meaning for example, the first record that is archived would have a 9 digit number, then the second record that is archived would hve 18 numbers and so on. I want for each archived record to have a unique 9-digit number generated from my own subroutine. Can someone plaese help me point in the right direction?

LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
if ($archive_list{$data[$db_key_pos]}) {
$archive_list{$data[$db_key_pos]} = 0;
if ($data[14] eq "Graduated" && $db_setup eq "academy") {

open (ARC, ">>$db_garchive_name") or &cgierr("error in archive_record. unable to open database: $db_garchive_name.\nReason: $!");
if ($db_use_flock) {
flock(ARC, 2) or &cgierr("unable to get exclusive lock on $db_garchive_name.\nReason: $!");
}
foreach $data (@data) {
$data =~ s/^\s+//g; # Trim leading blanks...
$data =~ s/\s+$//g; # Trim trailing blanks...
$data =~ s/\Q$db_delim\E/~~/og; # Change delimeter to ~~ symbol.
$data =~ s/\n/``/g; # Change newline to `` symbol.
$data =~ s/\r//g; # Remove Windows linefeed character.
}
$code = &my_subroutine();
print ARC "$code|$data[1]|$data[3]\n";
Julian
Quote Reply
Re: [vampy] Question about archive In reply to
what does "my_subroutine" do exactly?

what if you try to use "my $code" instead of "$code"?
kellner
Quote Reply
Re: [kellner] Question about archive In reply to
Code:
my $rand = join "", ('A'..'Z','a'..'z',0..9)[rand 64,rand 64,rand 64,
rand 64,rand 64,rand 64,
rand 64,rand 64,rand 64];

...hehe

Last edited by:

RedRum: Feb 3, 2002, 1:50 PM
Quote Reply
Re: [RedRum] Question about archive In reply to
Thanks for all your replies. I think I left out the fact that I need to use my own subroutine because it uses a algorithm to generate the numbers thus I need to put it as a subroutine and then access the subroutine in the archive mod.

Appreciate if you could help. Basically my subroutine just uses the algoritm to generate the numbers. I tested out the algortim on my own machine and each time it will only generate the 9 numbers I need. The only problem is when I try to access it in the archive mod. Then for every subsequent record I archive in a batch, it will just generate the same 9 numbers as the first record being archived followed by an additional 9 numbers.
Julian
Quote Reply
Re: [vampy] Question about archive In reply to
Unless you post the code of the subroutine you use, and a few lines of the code from where you call it, it's not possible to tell what's wrong.
kellner