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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.