Don't ask to ask, just ask | |
PerlMonks |
Re: Drawback of eval {---}if ($@){---}, when using many times?by kcott (Archbishop) |
on Oct 29, 2015 at 16:33 UTC ( [id://1146387]=note: print w/replies, xml ) | Need Help?? |
G'day rajuskark, "I am using eval block many time in my program is. I want to know is there any harm or any drawbacks if using it many times" There are drawbacks to using eval that are not related to the number of times it is used. See
Whether these drawbacks apply to your code will depend on what all the various '----'s are, as well as whatever code surrounds your while loop. As none of that is shown, you'll need to determine this for yourself. Your use of multiple 'eval{----};if($@){-----}' looks clunky and may be entirely unnecessary; that is, you may be able to use just one 'eval{----};if($@){-----}'. Here's a sample script to show how that might be achieved.
When run, this produces:
See also: the autodie pragma and the croak and confess functions of the Carp module. — Ken
In Section
Seekers of Perl Wisdom
|
|