in reply to Re^2: What's the better Perl style? Define parameters or not?
in thread What's the better Perl style? Define parameters or not?

Consider:

use strict; use warnings; my $obj = bless {}; # As function do_something (); # As method $obj->do_something (); sub do_something { my ($self) = @_; if ($self && 'main' eq ref $self) { print "Called as method\n"; } else { print "Called as function\n"; } }

Prints:

Called as function Called as method

True laziness is hard work