/[webpac2]/trunk/lib/WebPAC/Input.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by dpavlin, Sat Jul 16 11:07:38 2005 UTC revision 10 by dpavlin, Sat Jul 16 20:35:30 2005 UTC
# Line 26  Perhaps a little code snippet. Line 26  Perhaps a little code snippet.
26      my $db = WebPAC::Input->new(      my $db = WebPAC::Input->new(
27          format => 'NULL',          format => 'NULL',
28          config => $config,          config => $config,
29            lookup => $lookup_obj,
30            low_mem => 1,
31      );      );
32    
33      $db->open('/path/to/database');      $db->open('/path/to/database');
# Line 41  Perhaps a little code snippet. Line 43  Perhaps a little code snippet.
43    
44  Create new input database object.  Create new input database object.
45    
46    my $db = new WebPAC::Input( format => 'NULL' );    my $db = new WebPAC::Input(
47            format => 'NULL'
48            code_page => 'ISO-8859-2',
49            low_mem => 1,
50      );
51    
52    Optional parametar C<code_page> specify application code page (which will be
53    used internally). This should probably be your terminal encoding, and by
54    default, it C<ISO-8859-2>.
55    
56  This function will load needed wrapper module and  Default is not to use C<low_mem> options (see L<MEMORY USAGE> below).
57    
58  =cut  =cut
59    
# Line 52  sub new { Line 62  sub new {
62          my $self = {@_};          my $self = {@_};
63          bless($self, $class);          bless($self, $class);
64    
65          $self ? return $self : return undef;          $self->{'code_page'} ||= 'ISO-8859-2';
 }  
66    
67  =head2 open          my $log = $self->_get_logger;
68    
69  =cut          # running with low_mem flag? well, use DBM::Deep then.
70            if ($self->{'low_mem'}) {
71                    $log->info("running with low_mem which impacts performance (<32 Mb memory usage)");
72    
73  sub open {                  my $db_file = "data.db";
 }  
74    
75  =head2 function2                  if (-e $db_file) {
76                            unlink $db_file or $log->logdie("can't remove '$db_file' from last run");
77                            $log->debug("removed '$db_file' from last run");
78                    }
79    
80  =cut                  require DBM::Deep;
81    
82  sub function2 {                  my $db = new DBM::Deep $db_file;
83  }  
84                    $log->logdie("DBM::Deep error: $!") unless ($db);
85    
86                    if ($db->error()) {
87                            $log->logdie("can't open '$db_file' under low_mem: ",$db->error());
88                    } else {
89                            $log->debug("using file '$db_file' for DBM::Deep");
90                    }
91    
92                    $self->{'db'} = $db;
93            }
94    
95            $self ? return $self : return undef;
96    }
97    
98  =head1 MEMORY USAGE  =head1 MEMORY USAGE
99    

Legend:
Removed from v.3  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26