I am writing this code in perl where i create a unique key and then assign a value to it.
sub populate {
my $file = shift;
my %HoH = shift;
open(INFILE,$file);
.
.
.
$final_name = $prepend.$five;
$HoH{$final_name} = $seven;
}
Now i am passing in two parameters to a subroutine which id like
&populate(\%abc,$file_1);
&populate(\%xyz,$file_2);
Why does it give me an error like this:
Reference found where even-sized list expected
Because your hash is assigned to a reference, and not a hash (even-sized list). You need to do:
ETA: You should call subroutines without
&, e.g.populate(...), unless you specifically want to override the prototype of the sub. If you don’t know what a prototype is, just don’t use&.ETA2: You really should use a lexical filehandle and three-argument open. Consider this scenario: