develooper Front page | perl.perl5.porters | Postings from June 2012

Re: [perl #113792] Unused punctuation variables don't interpolate

Thread Previous
From:
Eric Brine
Date:
June 22, 2012 21:48
Subject:
Re: [perl #113792] Unused punctuation variables don't interpolate
Message ID:
CALJW-qHCG2n=gmJ0uZjgjNQXgzh6+Dm05T=ZXuDhdvECrEQqcA@mail.gmail.com
On Fri, Jun 22, 2012 at 7:55 PM, Tom Christiansen <tchrist@perl.com> wrote:

> > $ perl -E'@. = qw( a b c ); say "@{.}"'
>
> abc
>

>
What's up with *#4*?  How in the world is dot a legal
> name inside braces without quotes around it?
>

This isn't a dereference, this is Perl's interpolation delimiter.

That's why C<< "${foo}" >> is allowed with strict on.
That's why C<< "${Mod::foo}" >> is allowed.
That's why C<< "${.}" >> is allowed.

>perl -wE"use strict; my $foo=123; say qq{${foo}x}
123x
>perl -wE"use strict; our $foo=123; say qq{${main::foo}x}
123x
>perl -wE"use strict; say qq{${$}x}
5884x

Whoa, it's also allowed outside of a literal!

>perl -wE"use strict; my $foo=123; say ${foo}
123
>perl -wE"use strict; our $foo=123; say ${main::foo}
123
>perl -wE"use strict; say ${$}
5884

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About