But there should be no problem passing a reference to an arbitrarily complex data structure ...
Well it's insofar a problem that it's more complicated and unintuitive. Would you preferre to use HTML this way?
    <tag="a" name="anchor" ... >
"There should be no problem" to use a workaround is good argument to abandon Perl for the sake of a more primitive language.
But if you consider the Perl "named parameters" alternative to lengthy positional argument lists in function calls (especially where defaults may be involved) to be a complicated and unintuitive workaround, then just don't use it! It's a perfectly valid choice. (However, you may not have much luck in seeking for a solution among "more primitive" languages: I think few, if any, such languages offer anything other than positional function argument lists.)
Me, I can perfectly imagine a case where I'd like to pass anonymous functions with parameters (e.g to use as defaults):
    doit ( \&func1 => [para1, para2], \&func2 => [para7, para4] )
True, if you go anywhere near a hash with that argument list, you will stringize and therefore completely destroy the function references. So, don't do that!

However, consider this example, and consider what it would take to implement it as a function with a pure positional and possibly defaulted argument list:

use warnings FATAL => 'all'; use strict; doit({ func3 => [ \&up => [ qw(x y z) ] ] }); sub doit { my %defaults = ( func1 => [ sub { print map $_ . '1', @_ }, [ qw(a b) ] ], func2 => [ sub { print map $_ . '2', @_ }, [ qw(c d e) ] ], func3 => [ sub { print map $_ . '3', @_ }, [ qw(f g) ] ], ); my %args = (%defaults, %{ shift() }); for my $func (qw(func1 func2 func3)) { die "unknown func $func" unless exists $args{$func}; $args{$func}->[0]->(@{ $args{$func}->[1] }); print "\n"; } } sub up { print map uc, @_; }
Output:
a1b1 c2d2e2 XYZ
Again, it's a matter of personal preference: I know what looks better to me.

In reply to Re^14: Preferred technique for named subroutine parameters? by AnomalousMonk
in thread Preferred technique for named subroutine parameters? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.