On Oct 4, 2013, at 3:36 AM, Shaji Kalidasan wrote: > Dear Perlers, > > I am trying to figure out the flow of a try catch block after executing the > 'next' statement. In the try statement after illegal division by zero the > program flow reaches catch block and then executes the 'next' statement. > After executing the next statement the control flow has to skip the following > statement > > say "The sum of (@total) is $sum\n"; > > In otherwords, I want to ignore the say statement in case if an exception is > raised. (In the output of the given program, it is printing the total)
Put the foreach loop and the print sum statement inside the try block. To avoid a division by zero, test the divisor for zero before doing the division. Only depend upon exceptions for truly exceptional errors, i.e., those that cannot be anticipated. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/