Perl should have told you Global symbol "$temp" requires explicit package name at xxxxxxxxx line xx. Check your server's error log if CGI::Carp didn't catch the compilation error.
You can also use hash keys instead of a regex to untaint that data if its legal values come from a strictly-defined set. (I'm assuming you meant \. instead of . in your regex.) This saves the overhead of a regex and lets you untaint the data in O(1) time. (In this case, the difference will be negligible, but if you had a large number of items in the set it could make a difference.)
use constant TITLES => { 'Dr.' => 1, 'Prof.' => 1, 'Mrs.' => 1, 'Ms.' => 1, 'Miss' => 1, 'Mr.' => 1 }; my ($title) = $D_title =~ /^(.*)$/g if exists TITLES()->{$D_title};
(There might be a cleaner way to do this, perhaps without the ugly .*.)
Also, FYI, in general you can use $_ as a temporary variable and avoid a lot of $tmp and $temp floating around while making code that accesses that variable cleaner - but be sure to localize it first with local $_ = ..., or you may end up with scoping bugs that prove hard to track down.
Hope this helps.
In reply to Re: compilation error with 'strict' pragma on
by nightwatch
in thread compilation error with 'strict' pragma on
by itchybrownrobe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |