perl - Trying to use a while loop to ask the user if they want to do that again
<p>(New to perl)
I have a small perl program that calculates factorials. I'd like to use a while loop so that after the user gets a result, they will be asked "Calculate another factorial? Y/N" and have Y run the code again &amp; have N end the program.</p>

<p>Here's my code:</p>

<pre><code>print"Welcome! Would you like to calculate a factorial? Y/N\n";

$decision = &lt;STDIN&gt;;

while $decision == "Y";
{
    print"Enter a positive # more than 0: \n";

    $num = &lt;STDIN&gt;;
    $fact = 1;

    while($num&gt;1)
    {
        $fact = $fact * $num;
        $num $num - 1;
    }

    print $fact\n;
    print"Calculate another factorial? Y/N\n";
    $decision = &lt;STDIN&gt;;
}
system("pause");
</code></pre>

<p>What's giving me trouble is where to put the while loop and how to make the Y/N option work.  I'm also unclear about <code>system("pause")</code> and <code>sleep</code> functions. I do know that <code>system("pause")</code> makes my programs work though.</p>