As for the "Use of uninitialized value in substitution.." error..
This is because the string/value/thing you are trying to regex/match into, is not defined.
my $value_0;
my $value_1 = 'i have a defined value';
my $value_2 = 0;
$value_0=~/content/; # this will complain
$value_1=~/content/; # won't complain
$value_2=~/content/; # won't complain
So, one thing you can do to avoid the error is:
if ( defined $value_0 and $value_0=~/content/ ){
...
You can run the command 'perldoc -f defined' for more info.