Could someone lend me a hand in turning an expression (or specifically, the OP representing it) into an anonymous subroutine? Here's what I've got so far, which lends itself to weird bugs: /* op.c:Perl_ck_subr */ /* around line 6550 */ OP* kid = o2; OP* sib = kid->op_sibling; kid->op_sibling = 0; /* japhy */ o2 = newANONSUB( start_subparse(FALSE, CVf_ANON), Nullop, block_end(block_start(TRUE), kid) ); o2->op_sibling = sib; prev->op_sibling = o2; This is in an attempt to let sub foo (&@); parse foo /xyz/, @list; as it would parse foo { /xyz/ } @list; The thing I want to do is construct a OP_REFGEN op, which I see I can do using newANONSUB. The problem is that there seem to be some subroutine-scope issues around this new code-ref. For example: sub MY_MAP (&@) { my $cref = shift; for (@_) { print $cref->($_), "\n" } } MY_MAP /i/, qw( this is bad ); prints this1 is1 bad For some reason, the argument itself is being returned in addition to the return call. I put in that block_end(block_start ...) stuff in an attempt to alleviate the condition, but nope. Any suggestions? -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **Thread Next