Perl (Scripting) - Resolve "Reference found where even-sized list expected"

by
Jeremy Canfield |
Updated: April 22 2022
| Perl (Scripting) articles
Let's say something like this is being returned by your Perl script.
Reference found where even-sized list expected at example.pl line 16.
This typically occurs when the script contains something like this.
my %hash = {};
In Perl, there are 3 different kinds of hashes.
- A regular hash, which is defined by the % and ( ) characters, such as %hash = ( );
- A reference hash, which is defined with the $ and { } characters, such as $hash = { };
- A hash array, which is defined with the % and [ ] characters, such as %hash = [ ];
This can be resolved by correcting the script to define a regular hash.
my %hash = ();
my $hash = {};
my %hash = [];
Did you find this article helpful?
If so, consider buying me a coffee over at