radical hacks Generating Order Numbers for WebStore sent in the following hack...

# MODIFICATIONS added to effect the
# order number feature!!!

####################################
#    Sub get_order_number          #
####################################

sub get_order_number
  local ($index_path) = $sc_order_counter_path;
  local (%index_table) = ();
  %index_table = &get_index ($index_path);
  return %index_table;
  }

####################################
#  Sub get_index                   #
####################################

sub get_index {
  local ($index_path) = @_;
  my @db_row;
  my @db_definition;
  my $line='';

  open(INDEXVIRTUAL, "$index_path") ||
        &file_open_error("$index_path","Read
                   Index",__VIRTUAL__,__LINE__);
  flock INDEXVIRTUAL, $EXCLUSIVE;
  $line = ;
     #print "$line
"; @db_definition = split(/\|/,$line); while (!eof(INDEXVIRTUAL)) { $line = ; @db_row = split(/\|/,$line); $index_table{$db_row[1]} = $db_row[2]; #print "$db_row[1],$db_row[2]
"; } flock INDEXVIRTUAL, $UNLOCK; close (INDEXVIRTUAL); return %index_table; } #end of get_index subroutine #################################### # Sub update_order_number # #################################### sub update_order_number { local (%index_table) = @_; local ($index_path) = $sc_order_counter_path; &update_index ($index_path,%index_table); } #################################### # Sub update_index # #################################### sub update_index { local ($index_path,%index_table) = @_; local (@db_row); my $display_line=''; my $newline=''; my $line=''; open (INDEXVIRTUAL, "$index_path") || &file_open_error("$index_path","Reading Index",__VIRTUAL__,__LINE__); $line = ; $newline = $line; while () { @db_row = (); $line = $_; @db_row = split(/\|/,$line); $db_row[2] = $index_table{$db_row[1]}; $display_line = join "|",@db_row; $newline .= $display_line; #print "$display_line
"; } close INDEXVIRTUAL; open (INDEXVIRTUAL, ">$index_path") || &file_open_error("$index_path","Writing Index",__VIRTUAL__,__LINE__); flock INDEXVIRTUAL, $EXCLUSIVE; print INDEXVIRTUAL $newline; flock INDEXVIRTUAL, $UNLOCK; close INDEXVIRTUAL; } #end of update_index_counters subroutine # END of MODIFICATIONS!!! Then simply use: ($order_number) = &get_order_number; To fill the $order_number variable.

Updating the index is also required. The returned value is used and incremented in the calling method before the call is made to the update_order_number subroutine.

The fundamental methods to read and write an index are generic and reuseable for other purposes.