1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/usr/bin/env perl use warnings; use strict; use 5.10.0; my $new = Term_Choose->new(); say $new->choose( 1, 2 ); say Term_Choose::choose( 4, 6 ); package Term_Choose; sub new { my $class = shift; my $self = {}; return bless $self, $class; } sub choose { my $n = Term_Choose->new(); $n->choose( 1, 1, @_, 2, 2 ); } { no warnings 'redefine'; sub choose { my $self = shift; return @_; } } 1;
1 2 3 4 5 6 7 8
sub choose { if ( ! $_[0]->isa( 'Term_Choose' ) ) { my $n = Term_Choose->new(); return $n->choose( @_ ); } my $self = shift; return @_; }