Why is this program valid? I was trying to create a syntax error

后端 未结 6 1289
不思量自难忘°
不思量自难忘° 2020-11-28 17:04

I\'m running ActiveState\'s 32 bit ActivePerl 5.14.2 on Windows 7. I wanted to mess around with a Git pre-commit hook to detect programs being checked in with syntax errors.

6条回答
  •  暖寄归人
    2020-11-28 17:45

    As noted above this is caused by the indirect method calling notation. You can warn on this:

    use strict;
    use warnings;
    no indirect;
    
    Syntax error!
    
    exit 0;
    

    Produces:

    Indirect call of method "Syntax" on object "error" at - line 5.
    

    This requires the indirect CPAN module.

    You can also use no indirect "fatal"; to cause the program to die (this is what I do)

提交回复
热议问题