in reply to Re^2: Printing largest number in array using loops and if statement
in thread Printing largest number in array using loops and if statement
So, in this case, that line is equivalent toif (cond) { stmt; }
Personally, I prefer the method of initializing $max to the first (defined) item in the list so as to avoid testing !defined $max on every pass. The performance benefit of avoiding that test is negligible, of course, but it reads more cleanly to me when you're able to just say "remember this as the highest value if it's greater than the previous highest value" without the extra "and a highest value has been previously set" clause.if (! defined $max || $_ > $max) { $max = $_; }
|
|---|