dkhalfe has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. Here is my code
use strict; my $z = 0; for (my $d=1; $d < 10; $d++) { $z++; if ($z==1) { print $headers, "\n"; } else { print $body, "\n"; } }
Note: $headers and $body are defined elsewhere in my code and do not necessarily pertain to my question
Question: Is there a way to reset the $z variable to zero each time the for loop iterates? I am trying to print the header each time the loop iterates.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need to reset a variable to zero ??
by choroba (Cardinal) on Aug 06, 2012 at 17:32 UTC | |
|
Re: Need to reset a variable to zero ??
by rpnoble419 (Pilgrim) on Aug 06, 2012 at 21:40 UTC | |
|
Re: Need to reset a variable to zero ??
by abualiga (Scribe) on Aug 06, 2012 at 18:13 UTC |