in reply to filename flagged as Invalid argument

my $filename = <"Hashstructure.txt">;

Not entirely sure if it has to do with your problem, but why are you using globbing to declare the file name?  As a consequence of the glob, the file name will include the double quotes. I would rather try a simple

my $filename = "Hashstructure.txt";

Which OS are you using? Maybe it doesn't accept double quotes as part of a file name...