Instead of this:
my %services = ( service1 => { email => \@maintainers }, service2 => { email => \@maintainers }, );
You probably want this:
my %services = ( service1 => { email => [ @maintainers ] }, service2 => { email => [ @maintainers ] }, );
Below is an example showing what can happen when using/altering references. I make two references to a single scalar, alter one of the references and show that the contents of the original scalar and both references to that scalar change (but not a copy of the original).
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $a = "original"; my $a_ref1 = \$a; my $a_ref2 = \$a; my $a_copy = $a; say "\$a is $a"; say "\$a_ref1 is $$a_ref1"; say "\$a_ref2 is $$a_ref2"; say "\$a_copy is $a_copy"; say "OK, let's alter only the first reference (\$a_ref1):"; $$a_ref1 = "altered"; say "\$a is $a"; say "\$a_ref1 is $$a_ref1"; say "\$a_ref2 is $$a_ref2"; say "\$a_copy is $a_copy";
Output:
$a is original $a_ref1 is original $a_ref2 is original $a_copy is original OK, let's alter the first reference ($a_ref1): $a is altered $a_ref1 is altered $a_ref2 is altered $a_copy is original
In reply to Re: Putting an array into a hash gives an unexpected reference to the hash itself.
by frozenwithjoy
in thread Putting an array into a hash gives an unexpected reference to the hash itself.
by polarbear
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |