Yes, it will assign the blank string. But the warning is for mentioning an undefined value in the if test itself. It is only a warning. You should try to quite the warning with something like this:
if ( defined $value_a and $value_a =~ /personal/ ) {...

And one minor modification that no one seems to have mentioned yet would be to "factor" out the assignment with the ternary C<?:> operator, which also makes for a more concise but still fairly readable (actually, more readable IMHO) syntax like thus:

$value_a = defined $value_a && $value_a =~ /personal/ ? 'checked' : '' +;

Since in both cases $value_a would appear quite a number of times, and that makes the whole thing less readable, well at least for me, I feel like using a pronoun instead, that is a C<for> loop's aliasing property. In the second case this "trick" can easily be cast in the form of a statement modifier:

$_ = defined && /personal/ ? 'checked' : '' for $value_a;

But readability is such a subjective matter and this use so controversial that I won't certainly insist on it.


In reply to Re^2: Uninitialized Value Question by blazar
in thread Uninitialized Value Question by Anonymous Monk

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.