in reply to how to pass object to a subroutine

If moritz's second reading is correct and you want to print a representation of your object then you could look at overload to associate a subroutine with stringification of your object. Something along the lines of

use strict; use warnings; package MyModule; use overload q{""} => q{printObject}; sub new { ... } ... sub printObject { # print your attributes here } package main; my $obj = MyModule->new(some => q{args}); ... print qq{$obj}; ...

I'm not sure either from your post whether this is what you want but here's hoping.

Cheers,

JohnGG