★ wanayoo — archive 1999 http://www.wdvl.com/Authoring/Scripting/Tutorial/perl_while.htmlNouvelle recherche | Portail wanayoo
Internet Advertising Report logo
internet.com
Join the free
WDVL newsletter!

home

while

while

  • The while loop also performs iteration and in CGI scripts is primarily for reading lines in a file. The while loop can be used to read and print out every line of a file with the following syntax:

    open ([FILE_HANDLE_NAME], "[filename]");
         while (<[FILE_HANDLE_NAME]>)
           {
           print "$_";
           }
         close ([FILE_HANDLE_NAME]);
    

  • The script would print out every line in the file "filename" because the "$_", the Perl "default" variable, represents "the current line" in this case.

The process of opening and closing files is covered in the "File Management" section later.

Additional Resources:

foreach
Table of Contents
for Loops

Up to => Home / Authoring / Scripting / Tutorial


internet.com
e-commerce


Free Web Developer Info!

Copyright 1999-2000 internet.com Corp. Legal Notices. Privacy Policy.

www.internet.com