use strict;
use Carp qw(croak);
use vars qw($AUTOLOAD);
my %handler = (
hello => sub { print "Hello World\n" },
);
sub AUTOLOAD {
(my $fn = $AUTOLOAD) =~ s/.*:://g;
if (exists $handler{ $fn }) {
goto &{ $handler{ $fn } }
};
croak "Unknown method '$AUTOLOAD' called.";
};
hello();
####
use strict;
use Carp qw(croak);
use vars qw($AUTOLOAD);
sub AUTOLOAD {
(my $fn = $AUTOLOAD) =~ s/.*:://g;
my %handler = (
hello => sub { print "Hello World\n" },
);
if (exists $handler{ $fn }) {
goto &{ $handler{ $fn } }
};
croak "Unknown method '$AUTOLOAD' called.";
};
hello();
####
START:
goto INSIDE;
OUTSIDE:
if (0) {
INSIDE:
print "Hello ";
INSIDE2:
print "World\n";
};
####
my $handler = sub {
INSIDE:
print "Hello ";
INSIDE2:
print "World\n";
};
goto INSIDE; # deprecated
goto INSIDE2; # deprecated
goto &$handler; # still works, as we start "just on the outside" of $handler