KES777 / mojo

Mojolicious - Perl real-time web framework
http://mojolicio.us
Artistic License 2.0
0 stars 0 forks source link

Do not pass globals as arguments. They may be clobbered #2

Open KES777 opened 8 years ago

KES777 commented 8 years ago

Summary

Error is clobbered before we process it

Motivation

Arguments to functions are just aliases. When we process error we should copy $@ as soon as possible. When we pass $@ as argument we may implicitly loose its value

References

sub test { $@ = 'Oops'; my( $x ) = @_; print $x; # Oops } $@ = 'Exception'; test( $@ );