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.

0 Comments

Submit a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Network speed test host to host

On Ubuntu / Debian apt-get install iperf3 On Windows download it from https://iperf.fr/iperf-download.php#windows Make...

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...