ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/HashDB.pm
(Generate patch)

Comparing COMP/SCRAM/src/Utilities/HashDB.pm (file contents):
Revision 1.4 by williamc, Thu Oct 21 09:59:44 1999 UTC vs.
Revision 1.5 by williamc, Thu Oct 21 16:37:50 1999 UTC

# Line 85 | Line 85 | sub store {
85          my $fh=FileHandle->new();
86          open ($fh, ">$filename") or die "Unable to open file $filename\n $!\n";
87          foreach $object ( @{$self->{dataitems}} ) {
88 <          my $temp=join '::', $object->keys();
89 <          $temp=$object->data()."::".$temp;
90 <          print $fh $temp."\n";
88 >          # print the keys first then the data item
89 >          foreach $key ( $object->keys() ) {
90 >            print $fh "#".$key."\n";
91 >          }
92 >          print $fh ">".$object->data()."\n";
93          }
94          close $fh;
95   }
# Line 95 | Line 97 | sub store {
97   sub restore {
98          my $self=shift;
99          my $filename=shift;
100 <        my @arr;
100 >        my @arr=();
101 >        my $data;
102  
103          my $fh=FileHandle->new();
104          open ($fh, "<$filename") or die "Unable to open file $filename\n $!\n";
105          while ( <$fh> ) {
106 <          next if /^#/;
107 <          @arr=split ':', $_;  
108 <          $self->setdata(@arr);
106 >          if ( $_=~/^#(.*)/ ) {
107 >            push @arr, $1;      
108 >          }
109 >          if ( $_=~/^>(.*)/ ) {
110 >            $data=$1;
111 >            if ( $#arr >= 0 ) {
112 >             $self->setdata($data,@arr);
113 >            }
114 >            undef @arr;
115 >          }
116          }
117          close $fh;
118   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines