{ my $append = 0; my (@lines,$line,$saveout); CHECK { if ($append) { print STDOUT"}\n\n",@lines; open STDOUT, '>&', $saveout or die "Can't restore STDOUT: $!\n"; exec "vi +$line ". __FILE__; } } sub import{ shift; if (@_ && $_[0] eq 'append'){ $append = shift; my $func = shift || die "need function name to append.\n"; open $saveout, '>&', STDOUT or die "Can't dup STDOUT: $!\n"; open STDOUT, '+<', __FILE__; seek DATA,0,0; while() { last if /^"foo";$/} $line = $.; my $pos = tell(DATA) -7; @lines = ($_,); seek STDOUT, $pos, 0; print "sub $func {\n"; require O; O->import('Deparse'); }else{ no strict 'refs'; my $caller = caller; for(@_?@_: keys %y::){ next if /__ANON__/; *{$caller."::$_"}=\&$_; } } } }