Jim Cromie writes: > > since the qq:X family has recently come up, Id like to suggest another. > > qq:i {} is just like qq{} except that when it interpolates variables, > those which are undefined are preserved literally.
Eeeew. Probably going to shoot this down. But let's see where you're going with it :-) > for $memberfn (qw( foo bar belch )) { > # forgive errant? p5 syntax - I dont do this often > *{__PACKAGE__}::${memberfn} = eval sub qq:i { > > my $self = shift; # $self is undef when interpolated, > so preserved > $self->{member}{$memberfn} = 1; # $self preserved, $memberfn > interpolated > ... # presumably something useful (but not in this example) > } > or die "badness happend"; > } Yeah, well, you could try to write qq:i, but it's not going in the "standard dialect" any time soon. I think a good solution to this problem would be to find an uncommon character (well, this is Perl, so that doesn't really exist... but... you can find one), and call that the "interpolate" character. Then you could do (Perl6-land now): for <foo bar belch> -> $memberfn { &::($?PACKAGE)::($memberfn) := eval q:h:b('`')/END/; method ($self:) { $.member.{`{$memberfn}} = 1; # ... } END err die "badness" } Still not very pretty, but symbol table manipulation was never pretty. Anyway, the idea is that `{foo} evaluates foo and interpolates it. We could make that a standard parameter to :b (was it :b to interpolate {}? I don't remember), or we could make it a module. Whatever, I'd use it. Luke