Which seems to work. If you're looking for methods which act like functions and vice versa check out the source for CGI.pm as it performs a similar kind of magic.{ package PKG; sub safe_sub { my $self = shift if @_ == 3 and UNIVERSAL::isa($_[0], __PACKAGE__) or $_[0] eq __PACKAGE__; my($hash, $string) = @_; print $hash->{foo}, ':', $string, $/; } sub new { bless {}, shift } } my $obj = PKG->new(); print '$obj->safe_sub - '; $obj->safe_sub({'foo' => 'bar'}, 'cool'); print 'PKG->safe_sub - '; PKG->safe_sub({'foo' => 'bar'}, 'cool'); print 'PKG::safe_sub - '; PKG::safe_sub({'foo' => 'bar'}, 'cool'); package PKG; print 'safe_sub - '; safe_sub({'foo' => 'bar'}, 'cool'); __output__ $obj->safe_sub - bar:cool PKG->safe_sub - bar:cool PKG::safe_sub - bar:cool safe_sub - bar:cool
_________
broquaint
In reply to Re: Calling Madness
by broquaint
in thread Calling Madness
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |