This is a "symbolic reference", but happens to use a syntax that still passes strict.
Do you understand what happens here?
no strict qw(refs); my $variable = 'host_mail'; my ${ $variable } = '80.80.80.80';
How about this:
no strict qw(refs subs); my $variable = host_mail; my ${ $variable } = '80.80.80.80';
So it's not much of a stretch to get to this:
my ${ host_mail } = '80.80.80.80';
It's a little unusual to do. Usually strict disallows symbolic references, but in this case it allows it, because it's rarely harmful to do it. It's arguably poor style though, as it can result in confusion. (It confused you.)
The one place you do see it quite often though is in string interpolation:
my $scandal_topic = 'email'; say "We will call this scandal '${scandal_topic}gate'!"; # says "We will call this scandal 'emailgate'!";
That's because without the curlies we get:
my $scandal_topic = 'email'; say "We will call this scandal '$scandal_topicgate'!"; # dies "Global symbol "$scandal_topicgate" requires explicit package n +ame
In reply to Re: Curly braces variable
by tobyink
in thread Curly braces variable
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |