Use of uninitialized value in concatenation (.) or string at…

Written by James McDonald

October 15, 2009

I am trying to write Perl code which is warning free, unless there is a real problem.

Some of the code I was using to create an XML file using the “XML::DOM” Perl Module was throwing a “Use of uninitialized value in concatenation (.) or string at…” warning.

The warning thrown by XML::DOM ended up being unrelated to the XML I was trying to create and was instead caused by trying to use a variable that was undefined.

One answer (there are probably many better ways to do this in Perl) to this problem is to use

$variable = "" unless defined $variable;

Another thing I tried to help clean up my code was to put the “use warnings” pragma at the top of the script. It showed me some very specific warnings which enabled me to improve my dodgy coding aswell.


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...


Just downloaded WizTree (not a sponsor) from It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...