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

I had trouble attempting to dynamically build the equivalent of the @closures array using the "map {BLOCK}" syntax - apparently that conflicts with lvalue subs. }
sub : attribtute ... will be parsed at the beginning of a statement as "sub" being a label, and attribute... the code to run. Put a + in front of sub to disambiguate. Witness:
$ perl5.8.4 -we'sub xyzzy { print "huh?" } sub : xyzzy; shift() and go +to "sub"' 1 2 huh?huh?huh?
The makings of a fine japh here...
  • Comment on Re: Re: Getting a list of aliases to selected items from a list of array references
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Getting a list of aliases to selected items from a list of array references
by NetWallah (Canon) on May 16, 2004 at 17:07 UTC
    Excellent! - Many thanks, ysth - that worked great!
    # Replace @closures usage by this line in "sub map_With_Closure" &$sub( map {my $x=$_; +sub:lvalue{$x->[0]} }@_ ); # "+" required in front of sub, to avoid perl's mininterpration # of "sub" being a label, and attribute-- thanks ysth!
    The only minor gripe with this code is that it requires the use of the temporary variable $x , since $_ is local to the lvalue sub, and does not inherit from the "map".

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