Skip Menu |

This queue is for tickets about the PerlMol CPAN distribution.

Report information
The Basics
Id: 6833
Status: resolved
Priority: 0/
Queue: PerlMol

People
Owner: itub [...] cpan.org
Requestors: kevin.parkes [...] medivir.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)

Attachments


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
Download benzene.mol
chemical/x-mdl-molfile 891b

Message body not shown because it is not plain text.

The problem is that Chemistry::Ring doesn't "use warnings" (I forgot, shame on me!). That warning is "benign" in that having an undefined number of hydrogens should be considered the same as having zero hydrogens, so Perl's automatic undef -> 0 conversion is fine. When you start Perl with "#!/usr/bin/perl -w" you are activating warnings globally, which affects the Chemistry::Ring module as well, and as we can see this module is not warnings-clean. Thank you for letting me know; I'll make sure that the next version is warnings-clean. I just noticed that there are a few other modules where I didn't use warnings! Ivan