Adding +1 to $n won't work

The $n++; function is not working, so my "while' loop won't stop to do the "else" part of the script. Can someone help?
---------------------------------------
      $n=1;
      $card = "2142000".$n.".html";

      while($n > 0){
                                    $n++;
      if(-e "../valentine/cards/$card"){
      print "$card is being used.";
        }
      else{
      open(NEWCARD, ">../valentine/cards/$card");
          print NEWCARD "<html><head><title>$to\'s Valentine Card</title></head><body bgcolor=\"#ffe4e1\">";
          print NEWCARD "<font color=black face=\"Arial, Helvetica\">";
          print NEWCARD "<font color=crimson face=\"Arial, Helvetica\">Here is your Valentine's Day card!</font>\n";
          print NEWCARD "<table width=100\% height=100\%><tr><td align=center valign=center>";
          print NEWCARD "<img src=\"http://www.somewhere.com/valentine/$image\" border=0><br><br>";
          print NEWCARD "<font face=\"$font\" color=\"$fontcolor\">$to<br><br>$message<br><br>$salutation<br>$from</font>";
          print NEWCARD "</td></tr>";
          print NEWCARD "</table></body></html>";
          print "<B>Your card has been created!! The number is $card.</B>\n";
      close<NEWCARD>;
      exit;}
      }
     }
kch011099Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guadalupeCommented:
I believe you problem is that while you add 1 to n you do no reevaluate the value of card.  In every pass of the loop you check to see if card

21420001.html exists because when you do the assignment:

$card = "2142000".$n.".html"

$n get evaluated to 1 and stays that way for forever more...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kch011099Author Commented:
So what should I do to fix it?
0
guadalupeCommented:
Just move the $card assigment line after the $n++ like so:


     

      while($n > 0){

$n++;

$card = "2142000".$n.".html";
      if(-e "../valentine/cards/$card"){
      print "$card is being used.";

0
ozoCommented:
But be aware that if two people run the script simultaneously, they could open the same card.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.