Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday December 09, 2003
05:54 PM


[ #16249 ]

Just playing around, I wrote a small package that will let you do things like this:

use base 'Sub::Attributes';

sub reverse_me : Arrayref(NOVOID) {
    reverse @_;

The above function, if called in void context, will die. If called in list context will return its arguments. If called in scalar context will return a reference to its arguments. This is to solve the problem people face when they try to figure out which of twenty different ways to handle scalar context should they use this week. Return a reference, the first item (like &CGI::param), the last item, a count of items, etc. Currently, I only have the arrayref and an iterator implemented.

API suggestions and code critique are welcome.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • light (Score:3, Interesting)

    by djberg96 (2603) on 2003.12.09 18:27 (#26405) Journal
    Looks like a lightweight version of Not bad, though, as Want may be overkill for some folks.
    • Imagine if Want and Regexp::Common had sex. You have a handy predefined list of common behaviors that a user can assign to a subroutine without worrying about getting the exact syntax perfect. Just figure out which behavior you want for a given context and ask for it. You won't actually have to set up the behaviors for the different contexts, though. It gets done for you, thus lowering the number of bugs.