develooper Front page | perl.perl5.porters | Postings from March 2021

Re: Perl feature wish: quote-word array-ref operator

Thread Previous | Thread Next
H.Merijn Brand
March 12, 2021 09:36
Re: Perl feature wish: quote-word array-ref operator
Message ID:
On Thu, 11 Mar 2021 12:43:42 -0500, Dan Book <> wrote:

> On Thu, Mar 11, 2021 at 3:30 AM Alexander Hartmaier <
>> wrote:  
> > What I hate about quoting in Perl in general is that it doesn't
> > allow to use the dash! my %hash = ( foo-bar => 'baz' ); doesn't
> > work and needs to be quoted.  
> Just FYI this is because Perl identifiers don't consider hyphens to
> be word characters (a decision that Raku, as mentioned, has done
> differently). This applies to all types of identifiers such as
> variable and package names, bareword hash keys are just one place
> where identifier rules are used:

But the fat comma already makes an exception for leading dashes:

$ perl -MData::Dumper -E'say Dumper ({ -key => 42, -value => "Boo" })'
$VAR1 = {
          '-key' => 42,
          '-value' => 'Boo'

So it *is* possible. I have no idea what the impact would be and I did
not yet make up my mind if I want it myself.  Also no idea how much it
would break (no breakage is an option to consider).

> -Dan

H.Merijn Brand   Perl Monger
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About