in reply to How called was &I?

You can pretty much determine exactly how you were called
use strict; use warnings; { package foo; use UNIVERSAL qw(isa); sub new { bless {}, shift } sub callme { my $invoker = (@_ == 2 ? shift : ''); my $package = [caller]->[0]; if(ref $invoker and isa($invoker, __PACKAGE__)) { if($package ne __PACKAGE__) { print 'called: $obj->method(@args)', $/; } else { print 'called: method($obj, @args)', $/; } } elsif($invoker eq __PACKAGE__) { if($package ne __PACKAGE__) { print 'called: foo->method(@args)', $/; } else { print 'called: method("foo", @args)', $/; } } elsif($invoker eq '') { if($package ne __PACKAGE__) { print 'called: foo::method(@args)', $/; } else { print 'called: method(@args)', $/; } } } } my $o = foo->new; my $arg = 'a string'; $o->callme($arg); foo->callme($arg); foo::callme($arg); callme $o $arg; # same as $o->callme($arg); # callme 'foo' $arg; # syntax error { package foo; callme($o, $arg); callme('foo', $arg); callme($arg); } __output__ called: $obj->method(@args) called: foo->method(@args) called: foo::method(@args) called: $obj->method(@args) called: method($obj, @args) called: method("foo", @args) called: method(@args)
Of course this is assuming you know how many arguments you're expecting in your method, but it shouldn't be too hard to get around that.
HTH

_________
broquaint