my $foo = new Foo; $foo->dump; # dumps automatically to STDERR print $foo->dump; #dumps to STDOUT print FOO $foo->dump; # dumps to filehandle FOO #### a->dump( $foo ); # dumps automatically to STDERR print a->dump( $foo ); #dumps to STDOUT print FOO a->dump( $foo ); # dumps to filehandle FOO #### sub UNIVERSAL::dump { # Obtain the object / class # Make sure that we have Data::Dumper # Return Dumper output if not in void context # Send Dumper output to STDERR otherwise my $self = shift; require Data::Dumper; return Data::Dumper::Dumper( @_ ? @_ : $self ) if defined wantarray; print STDERR Data::Dumper::Dumper( @_ ? @_ : $self ); } #UNIVERSAL::dump