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…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...