On Mon, 26 Sep 2005, Jon Pettersen wrote: > I have just started to look at Perl Running version Active Perl > 5.8.7.813 on Windows XP. > > I am trying to program a script/program ( to run in command prompt)to > calculate empirical and molecular formulas . > > Percentage of f.ex C and H is given and the empirical formula is > printed on the screen. Formula weight is going to be used for the > molecular formula and the reult is of course printed on the screen.
> It would be nice if the symbols and atom weight could be entered from > the keyboard to be able to calculate different types [...] > > [...] but actually if someone could show me a script that fixes the > calcultaion with C and H I would be quite happy. > > I can not find anything in the Perl books I have that "shows me the > way" to solve this. Would be nice if it is done as easy as possible or > I will not understand a thing of how it is done ;-) > > Feelingsostupid. Start small. Break your task up into manageable chunks. If the chunks still seem overwhelming, break them up further. Keep breaking things down until you have nuggets of required functionality that you can digest. One popular way to break things up is with paragraphs! :-) Think through what you need to do. Put broadly, that might mean: 1. accept input from the user 2. validate that the input is useful 3. perform your calculations on that input as needed 4. prepare the processed data for output to the user 5. output it in a useful way (console output, CGI, save to file, etc) Of these, 1., 4., and 5. are sufficiently generic that you could almost look them up as is in a book like _Perl Cookbook_; 2. is only slightly more specific, and can also be found in such a book if you poke around for a bit. That just leaves 3., the calculations, which depend on the details of your problem. You yourself need to figure out how to express this work as a series of algebraic statements that can be coded in Perl (or any other language). We can maybe help you with the other steps, if you at least get started with them on your own, but you'll have to come up with a way to do the chemical calculations based on your own needs. So, the canned answer: what have you tried so far? Can you take a shot at working on smaller aspects of your problem and getting everything working together from there? Give it a try, then if you get stuck feel free to come back to the list with specific questions and code. -- Chris Devers ÁS¶9êN¢9
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>