Lexical Attributes

A week or two ago, I took an idea from Aristotle about “shortcut” functions and made it into a little module: Attribute-Shortcut. Aristotle pointed out in the comments that the attributes should also work on coderefs as well as named subs. i.e.

  sub basename :Shortcut { s!.*/!! for @_ };
  my $basename = sub :Shortcut { s!.*/!! for @_ };

However, I can’t seem to find a way to make this work. Attribute::Handlers passes you the string “ANON” instead of a glob reference.

Looking deeper at the documentation for attributes, it seems to imply that attributes on lexical variables aren’t really very well supported anyway.

I think I may have to conclude that this isn’t going to work for now…