loops - is there a tidy way to adhere to 'strict' and 'warnings' parameters when constructing "until (EXPR) BLOCK" statements in perl? -
Using the following code as a reference ...
#! Strict use of / usr / bin / perl; Use warnings; My $ counter = 0; Until ($ counter == 10) {$ counter ++; } $ Print counter; .. By doing so, the $ counter variable is accessible to the loop, so running this will print "10".
However, it has been haunting me .. How can I declare in compliance with $ counter varible, 'Use of warnings' (and possibly hard), but as long as it is within the loop Impossible. Whilst I'm not an expert ... After being coded in Perl for some years, the work should be done in the following ways ...
#! Use / usr / bin / perl strict; Use warnings; Unless (my $ counter == 10) {$ counter ++; } But it seems that the first counter has not been declared as a numerical value, and because we are using expression ==, the following warning is printed .. test.pl In the numerical EC (==) on line 5, use the uninitialized value $ counter. I know that it may look anal but I have to complete the shoulder that I am getting!
Use: (my $ counter = 0 ; $ Counter! = 10; $ counter ++) {...; } Or better yet,:
for my $ counter (0 .. 9) {...; }
Comments
Post a Comment