Perlmonks,
I have a question about strict vars and the code segment below. I get a compilation error that goes away when I turn off the strict pragma.
I am trying to parse html form data with a regex. I want to accept only what I consider appropriate data in each form field. Also, I want to eventually save this info to a database so, as I understand it I have to untaint it (another reason for the regex). I bring each field of the form into a variable prefaced with a D for dirty, untaint it then grab the regex backreference with the variable of the same name, minus the 'D'.

Below is the beginning of my script. I plan to use Time::Local but am not right now, so it is commented out and, I think, not a factor. What I have is a series of declarations followed by the regex stuff. Perhaps its not the most elegant way to do this, but I can not figure out why, since no loops, if-else clauses, or subroutines factor into this series of matches and assignments, the strict pragma does not like it. As I understand it, these variables are all file scope and should therefore be OK to 'strict'. If I turn strict on and then add 'no strict vars' the script will compile.
Thanks
itchybrownrobe

#use strict; use warnings; #use Time::Local; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $sec = 0; my $min; my $hours; my $D_title = param('title'); my $title; . . . #___________start_untainting_form_input_________ $temp = ($D_title =~ m/^(Dr.|Prof.|Mrs.|Ms.|Miss|Mr.)$/ ); $title = $1;

In reply to 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.