Subject: | conflicting tests in some cases |
If the last line of code in a subroutine is a die() or exit(), I get the
severity 4 warning:
Subroutine does not end with "return" at line 11, column 1. See page
197 of PBP. (Severity: 4)
If I try to fix this by adding a return as the last line of code I then
get the severity 4 warning:
Unreachable code at line 8, column 5. Consider removing it. (Severity: 4)
So, which should I do? It would be nice if Perl::Critic could come up
with a solution to this situation.
I've attached a simple perl script with two subs which demonstrates the
problem.
Thanks,
Stephen Quinney
Subject: | critic-test.pl |
#!/usr/bin/perl
use strict;
use warnings;
sub test1 {
die "foo\n";
return;
}
sub test2 {
die "foo\n";
}