use strict; use warnings; use feature 'say'; { package Test; sub new { my $class = shift; my $ref = shift; return bless \$ref, ref $class || $class; } sub send { my $self = shift; my $data = shift; use Data::Dumper; say Dumper $$self; # ==> $VAR1 = \*{'::$file'}; so it is a GLOB ref print $$self $data; #the following does not warn... #~ my $fh = $$self; #~ print $fh $data; } } open my $file, '>', 'test.txt' or die $!; my $t = new Test($file); $t->send("foo"); close $file; #### sub output { my ($self, $data) = @_; print $$self $data; }