use IO::File; my $fh = new IO::File; my %hash = ( file1=>$fh ); $hash{ file1 }->open(">subcat.txt") or die $!; print $hash{ file1 } "Text here\a"; $hash{ file1 }->close();