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 ]

james (1129)

  (email not shown publicly)


Journal of james (1129)

Friday June 15, 2001
09:36 AM

Near miss

[ #302 ]

Well, after seeing MJD do his 'Tips and Tricks' talk I was
somewhat inspired (I'd wanted to see it for quite a while).
So I tried this out:

package Whatever;
sub new {
    my $class = shift;
    my $arg2 = shift;
    my $lexical;
    return bless sub {
        sub arg2 {
            return $arg2;
    }, $class;

package main;

$n = Whatever->new( 'this' );
print $n->arg2();

and it appeared to work. However, MJD pointed out that if
you instantiate the object twice it falls over (although
the closure gets a new pad the subs inside the anonsub
obviously -- in retrospect -- don't). Ah well. It would
have been nice syntax, but it didn't quite work for now
apparant reasons.

Overall the conference is good -- I'm coming away with some
good ideas for talks, and picking up bits and pieces that
are interesting. Tonight I'm out with friends from
Montreal, so I should be reasonably hung over tomorrow. :-)

Just in: I've realized that these are actually natural singletons with no extra trickery required.