Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (62 sloc) 1.158 kb
#!/usr/bin/perl
# Copyright 2004, Paul Johnson (pjcj@cpan.org)
# This software is free. It is licensed under the same terms as Perl itself.
# The latest version of this software should be available from my homepage:
# http://www.pjcj.net
sub gen
{
my $x = shift;
sub
{
my $y = shift;
return $x + $y if $y;
}
};
my $o = gen(1);
my $p = $o->(7);
my $q = $o->(8);
my $r = gen(1)->(2);
my $s = gen(3)->(4);
my $t = gen(5)->(6);
print "$p, $q, $r, $s, $t\n";
sub call { caller }
for my $func (qw(f1 f2 f3))
{
no strict "refs";
*$func = sub
{
my $self = shift;
print "$func\n";
# print join " ", call, "\n";
}
}
f1();
f2();
sub AUTOLOAD
{
my ($self) = @_; # don't change @_ because of the goto
my $func = $AUTOLOAD;
# print "autoloading $func\n";
$func =~ s/^.*:://;
no strict "refs";
if ($func eq "add")
{
*$func = sub
{
print "Add!\n";
};
}
else
{
*$func = sub
{
print "$func\n";
};
}
goto &$func
}
add();
add();
add();
qaz();
wsx();
Jump to Line
Something went wrong with that request. Please try again.