Help for this page

Select Code to Download


  1. or download this
    use Parse::RecDescent;
    
    ...
    
    print $g->weight("Pb(CO3)2"), $/;
    # prints 327
    
  2. or download this
      weight   : compound         { $item[1] }
      compound : group(s)         { sum( @{$item[1]} ) }
    ...
               |                  { 1 }
      element  : /[A-Z][a-z]*/    { $weights{ $item[1] } }
               | "(" compound ")" { $item[2] }