Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I shorten a [ qw( ... ) ] construct in Perl?

Perl's quote-like operator qw() creates a word list from barewords, while square brackets [] can be used to create references to anonymous arrays. Now, I was wondering if Perl provides a way to somehow abbreviate this:

my $aref = [qw( a b c )];

using something like a non-existent qa() operator:

my $aref = qa( a b c );

I've been using qw() and [] together quite a lot recently, and all I want is to reduce cluttering.

Note: This is not what I'm looking for:

my @a = \( qw( a b c ) );
like image 482
n.r. Avatar asked Oct 29 '25 13:10

n.r.


1 Answers

Not core Perl, but check out Syntax::Feature::Qwa

like image 141
Diab Jerius Avatar answered Oct 31 '25 05:10

Diab Jerius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!