Chemistry::Elements

Chemistry::Elements is a Perl extension for working with Chemical Elements.
Download

Chemistry::Elements Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • brian d foy
  • Publisher web site:
  • http://search.cpan.org/~bdfoy/

Chemistry::Elements Tags


Chemistry::Elements Description

Chemistry::Elements is a Perl extension for working with Chemical Elements. Chemistry::Elements is a Perl extension for working with Chemical Elements.SYNOPSIS use Chemistry::Elements qw(get_name get_Z get_symbol); # the constructor can use different input $element = new Chemistry::Elements $atomic_number; $element = new Chemistry::Elements $chemical_symbol; $element = new Chemistry::Elements $element_name; # you can make up your own attributes by specifying # a method (which is really AUTOLOAD) $element->molar_mass(22.989) #sets the attribute $MM = $element->molar_mass #retrieves the valueThere are two parts to the module: the object stuff and the exportable functions for use outside of the object stuff. The exportable functions are discussed in EXPORTABLE FUNCTIONS.Chemistry::Elements provides an easy, object-oriented way to keep track of your chemical data. Using either the atomic number, chemical symbol, or element name you can construct an Element object. Once you have an element object, you can associate your data with the object by making up your own methods, which the AUTOLOAD function handles. Since each chemist is likely to want to use his or her own data, or data for some unforesee-able property, this module does not try to be a repository for chemical data.The Element object constructor tries to be as flexible as possible - pass it an atomic number, chemical symbol, or element name and it tries to create the object. # the constructor can use different input $element = new Chemistry::Elements $atomic_number; $element = new Chemistry::Elements $chemical_symbol; $element = new Chemistry::Elements $element_name;once you have the object, you can define your own methods simply by using them. Giving the method an argument (others will be ignored) creates an attribute with the method's name and the argument's value. # you can make up your own attributes by specifying # a method (which is really AUTOLOAD) $element->molar_mass(22.989) #sets the attribute $MM = $element->molar_mass #retrieves the valueThe atomic number, chemical symbol, and element name can be retrieved in the same way. $atomic_number = $element->Z; $name = $element->name; $symbol = $element->symbol;These methods can also be used to set values, although changing any of the three affects the other two. $element = new Chemistry::Elements('Lead'); $atomic_number = $element->Z; # $atomic_number is 82 $element->Z(79); $name = $element->name; # $name is 'Gold' Requirements: · Perl


Chemistry::Elements Related Software