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

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

Thread Previous | Thread Next
Paul "LeoNerd" Evans
March 5, 2021 11:21
Re: Perl feature wish: quote-word array-ref operator
Message ID:
On Fri, 5 Mar 2021 08:48:25 +0000
Neil Bowers via perl5-porters <> wrote:

> It would be handy to have a "quote word arrayref operator" in Perl,
> that combines [] with qw.
> So instead of writing:
>     $a = [ qw/ one two three/ ];
> You could write:
>     $a = qa[ one two three ];

Implementation-wise that wouldn't be too hard to add. Though I'd have
one concern about deparse. Namely, what would you expect to see from:

  $ perl -MO=Deparse -ce '$x = [qw[ one two ]]; $y = qa[ three four ]'

Would the deparse show the difference in these originally, or would
they both come out using the same notation? Already a qw[] gets lost:

  $ perl -MO=Deparse -ce '$x = [qw[ one two three ]]'
  $x = ['one', 'two', 'three'];

So perhaps qa would do the same?

Paul "LeoNerd" Evans      |  |

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