David,

Not quiet... but appreciate the feedback... it did give an idea to another more easier approach to the process and it seems to be working,... so far.

thanks,

>> david wrote:
David wrote:


does the following do what you want:

sub update_categories{
       my $data_files = shift;
       my $main_cat   = shift;
       my $sub_cat    = shift;
       open(CAT,$data_files) || die $!;
       while(<CAT>){
               close(CAT) and return if(/$main_cat\::$sub_cat/); #-- 1.
       }
       close(CAT);
       open(CAT,">>$data_files") || die $!;
       print CAT "$main_cat\::$sub_cat\n"; #-- 2.
       close(CAT);
}

1. return and do nothing if $main_cat::$sub_cat already exists in the file
2. add to the end of the data file if $main_cat::$sub_cat does not exists


thinking about it after a while, probably better as:

sub update_categories{
        my $data_files = shift;
        my $main_cat   = shift;
        my $sub_cat    = shift;
        open(CAT,"+>>$data_files") || die $!;
        while(<CAT>){
                close(CAT) and return if(/$main_cat\::$sub_cat/);
        }
        print CAT "$main_cat\::$sub_cat\n";
        close(CAT);
}

david




-- Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Web Hosting http://www.justlightening.net Tel: 1(985)902-8484 MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to