note
LanX
You can't get rid of the sigils <C>$%@</C> in Perl, because of conflicts with barewords which have many other meanings and the many bultin commands which depend on sigils.<P>
But this last example of aliasing a list-form and hashref-form <C>\%hsh = $hsh</C> could be simplified, such that the deref <C>-></C> isn't needed anymore.<P>
use [METAMOD://Keyword::Simple] to define a new command like e.g. <C>var</C> or <C>let</C> and any<P>
<C>var %hsh = LIST;</C><P>
is translated to<P>
<C>my $hsh = \ my %hsh; %hsh = LIST;</C><P>
This is not too hard to implement, because you don't need to parse LIST in advance (which could be arbitrary Perl code)<P>
Like this <U>explicit</U> dereferencing with -> would be "simplified" away.<P>
Demo:<P>
<c>
DB<27> sub LIST { foo => { x => 42 } }
DB<28> $bar ='x'
DB<29> my $hsh = \ my %hsh; %hsh = LIST; \\
cont: say $hsh{foo}{$bar}
42
</c><P>
Of course that way you'd loose the ability to have $ident and %ident in different namespaces, but that's often considered bad style anyway.<P>
And passing of hash-refs, like with function-parameters wouldn't be that easy without additional \ref-operation<P>
<c>
sub func {
var (\%hsh,\@arr) = @_;
}
</c><P>
because otherwise var couldn't tell if a $scalar is meant to be aliased to a %hash or an @array <P>
<c>
sub func {
var ($hsh,$arr) = @_; # ???
}
</c><P>
tho you might be able simplify the syntax in many cases with <P>
<c>
sub func {
var \(%hsh,@arr) = @_;
}
</c><P>
HTH! :)
<div class="pmsig"><div class="pmsig-708738">
<!--nowiki--><p>Cheers Rolf<br>
<sub>(addicted to the Perl Programming Language :)
<br> <i> [id://1153804|Wikisyntax for the Monastery]</i>
</sub>
<!--nowiki-->
</div></div><!-- Wiki2Monks {"version":1.161} -->
11139815
11139833