Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Chemistry::Elements 1.05

    Download button

    No screenshots available
    Downloads: 430  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.5/5)
    12 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    brian d foy | More programs
    Perl Artistic License / FREE
    February 3rd, 2008, 07:50 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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 value

    There 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 value

    The 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'

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Chemical Elements | Perl class | Perl module | Chemical | Elements | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM