6 my $schema = SMIDDB
->connect('dbi:Pg:dbname=smid_db;host=localhost;user=postgres;password=DebianBox**');
8 my $compounds = $schema->resultset("SMIDDB::Result::Compound")->search( {} );
10 while (my $compound = $compounds->next()) {
11 my $molecular_weight = molecular_weight
($compound->formula());
13 $compound->update( { molecular_weight
=> $molecular_weight });
20 sub molecular_weight
{
22 #The default variable will be used as the chemical Formula
142 my @pairs = /([CHONPS][0-9]*)/g;
143 foreach my $pair (@pairs){
144 if (length($pair)==1){
145 $weight += $elements{substr($pair, 0, 1)};
147 $weight += $elements{substr($pair, 0, 1)}*substr($pair, 1);