in reply to Uninitialized Value Question
If your database column contains a NULL in this column then $value_a will contain the Perl value "undef". The warning you are getting is saying that you are trying to match a regular expression against an undefined variable.
You probably want to change the code to something more like this:
if (defined $value_a) { if($value_a =~/personal/) { $value_a = "checked"; } else { $value_a = ''; } } else { $value_a = ''; }
You should also consider whether you really want to check the value of the variable using a regex match. If you just want to check that the value is "checked", then using the string equality operator will be more efficient.
if (defined $value_a) { if($value_a eq 'personal') { $value_a = 'checked'; } else { $value_a = ''; } } else { $value_a = ''; }
Update: Fixed a couple of typos (thanks johngg)
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
|---|