I struggled a bit before I got this code to work - the code below includes kvale's Reference-passing method (shortened by 2 bytes of code), and an alternative using closures and lvalue subs - not the most elegant, but it was fun experimenting with them..
sub map_With_Ref { my( $sub )= shift( @_ ); &$sub( map { \$_->[0] } @_ ); # ^^^^^^^^^^^^^^^^^^ Here is the selection code } sub map_With_Closure { my( $sub )= shift( @_ ); my @closures; foreach my $aref(@_){ push @closures, sub :lvalue{ $aref->[0] }; } &$sub( @closures ); # I had trouble attempting to dynamically build the equivalent of +the # @closures array using the "map {BLOCK}" syntax - apparently that # conflicts with lvalue subs. } my @a= ( 1..3 ); my @b= ( 4..6 ); my @c= ( 7..9 ); sub addten_Ref { $$_ += 10 for @_ } sub addten_With_Closure { &$_() += 10 for @_ } print "--- REF test --\n"; map_With_Ref( \&addten_Ref, \@a, \@b, \@c ); map_With_Ref( sub { print "$$_\n" for @_ }, \@a, \@b, \@c ); print "--- Closure test --\n" ; map_With_Closure( \&addten_With_Closure, \@a, \@b, \@c ); map_With_Closure( sub { print &$_() . "\n" for @_ }, \@a, \@b, \@c );
################### --Output -- --- REF test -- 11 14 17 --- Closure test -- 21 24 27
If anyone is successful in enclosing the lvalue sub inside a "map" statement, I'd love to see the code.

Offense, like beauty, is in the eye of the beholder, and a fantasy.
By guaranteeing freedom of expression, the First Amendment also guarntees offense.

In reply to Re: Getting a list of aliases to selected items from a list of array references by NetWallah
in thread Getting a list of aliases to selected items from a list of array references by tye

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.