On Nov 17, angie ahl said: >I keep getting hung up on deciding whether to use for or while for >loops.
Well, it usually depends on how the code "reads". I use 'while' for loops based on a condition that will change in some execution of the block. while (<FILE>) { # eventually, <FILE> will return undef when the file is exhausted } while ($i < 5) { # $i will be changed somehow # eventually it will be greater than or equal to 5 } while ($x or $y or $z) { # continue while one of those three variables is still true } It's important to note that while (<FILE>) { ... } is identical to while (defined($_ = <FILE>)) { ... } which only reads ONE line at a time, whereas for (<FILE>) { ... } reads ALL the lines of the file at once, into a list. A for loop is best used for iterating over a list of values, or, in the C-style loop, running through a range. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]