perlguru22 has asked for the wisdom of the Perl Monks concerning the following question:
So if the user inputs H22011C12 it would give me H 22 0 11 C 12 all seperate so my next step is to pass that array into a subroutine. I know I have to multiply the weight of the symbol by the occurrence so if the weight of H is 12.01 I multiply by 22 and so on than I add all the totals I just can't seem to figure out how to start my subroutine I have a weights file goes with this. I was just hoping so one could give me some guidence or explain the process to me Thank you so much.Print "enter a formula.\n"; chomp ($form=<STDIN>); @array = $form =~ /[A-Z][a-z]?|\d+/ig
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formula program
by mbethke (Hermit) on Nov 28, 2012 at 06:15 UTC |