|Think about Loose Coupling|
Not shown as an Update in your OP:
I am getting syntax error at near ");" at while (0). How do you fix it?
To be honest, I find your reply quite unbelievable. Four monks responded to your post yesterday: davido (in Re: Perl Loops) answered the very question you're now asking; vinoth.ree (in Re: Perl Loops) showed a code example of how to do it; farang (in Re: Perl Loops) and rjt (in Re: Perl Loops) pointed you to documentation for this loop construct.
Go back and read the advice, code and documentation provided. Then make some effort yourself!
Also read "How do I change/delete my post?".
Update: Added the names of the four monks and links to their specific posts.