Subject: | undef errors in Chemistry::Ring and Chemistry::Ring::Find |
I've found that find_ring method in Chemistry::Ring::Find and is_aromatic method in Chemistry::Ring generate "Use of uninitialized variable..." errors under some circumstances. I've unfortunately not yet found a simple way of reproducing the first problem although the errors are from lines 139, 141, 185 and 186 of Chemistry/Ring/Find.pm. However the is_aromatic error in line 140 of Chemistry/Ring.pm is reproduced by the following script using the attached benzene.mol file.
#!/usr/local/bin/perl -w
use strict;
use warnings;
use Chemistry::Mol;
use Chemistry::File::MDLMol;
use Chemistry::Ring::Find ':all';
my $mol = Chemistry::Mol->read("benzene.mol");
my @carbons = grep {
$_->symbol eq 'C'
} $mol->atoms;
my @ring = find_ring($carbons[0]);
print "Aromatic\n" if $ring[0]->is_aromatic;
#######################################################
Which gives the following output:
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Use of uninitialized value in addition (+) at /usr/local/lib/perl5/site_perl/5.8.4/Chemistry/Ring.pm line 140.
Aromatic
I can work around this problem (but not the find_ring one) by looping through the atoms setting the hydrogen count:
foreach $i (@ring) {
foreach $j ($i->atoms) {
unless ($j->hydrogens) { $j->hydrogens(0) };
}
}
My perl is: v5.8.4 built for i686-linux.
My OS is: Linux thor 2.4.18-3smp #1 SMP Thu Apr 18 07:27:31 EDT 2002 i686 unknown
Message body not shown because it is not plain text.