in reply to Can I rewrite this code?
I doubt it's a good idea, since you might still want to pass more positional parameters. Otherwise you could just pass a list func(a=>1) with sub func { my %args = @_}
But for completeness a solution with the new refaliasing feature
use strict; use warnings; use Data::Dump qw/pp dd/; use feature qw/refaliasing/; no warnings "experimental::refaliasing"; sub tst { (\my %args) = @_; pp \%args; } tst({a=>1,b=>2});
C:/Perl_524/bin\perl.exe d:/tmp/pm/refaliasing.pl { a => 1, b => 2 }
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|