I've fixed all the problems that I can see but it still throws me the wrong way. Now what ever I enter in the confirm sub activates the else tag of the if statement. And sends me back to confirm()!!! Heres what I've done: (I ran it with warnings on.)
#To determine the pattern of fish reproducing #in a pond start(); sub start{ print "Welcome to the 'Fish in a Pond' chaos theory solution guide +.\n" . "Please enter the number of fish in the pond on the f +irst year:\n"; print "\n"; $nof = <STDIN>; print "\n"; print "Please enter the anual rate of increase: \n"; print "\n"; $roi = <STDIN>; print "\n"; print "For what period of time would you like the simulation t +o run for(in years): \n"; print "\n"; $yrs = <STDIN>; chomp($nof); chomp($roi); chomp($yrs); $confirm = confirm(); if ($confirm eq 'n') { start(); } elsif($confirm eq 'y') { middle(); } else{ print "Please enter either Y or N. \n"; confirm(); } } sub middle{ $ans = $nof; $year = 0; print "Year $year. = $ans fish."; print "\n"; calc(); } sub calc{ while($year <= $yrs) { $year = $year + 1; $i = $ans * $roi; $x = 1 - $ans; $ans = $i * $x; print "Year $year. = $ans fish. \n "; } } sub confirm{ print "The data that you have entered says: \n" . " * that there is $nof thousand fish in the pond on the fisrt +year.\n" . " * that the annual rate of increase is $roi. \n" . + " * that the simulation will run for $yrs years. \n\n"; print "Is this information correct?(Y/N): "; $answer = <STDIN>; $answer =lc($answer); return($answer); }
Help please.
All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.


In reply to Re: Re: A missleading sub by eoin
in thread Trouble with flow control by eoin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.