There is no such thing as returning a hash in Perl.
Routines take lists as their arguments and can return lists as their results. Note that a list is a completely different creature from the array.
When you write
return %fileDetails;
This is equivalent to:
return ( 'something', 0, 'somethingelse', 7.68016712043654, 'else', 'burst' );
When you call a routine and return this list, one thing you can do is assign a new hash to it:
my %result = fileDetailsSub();
This works because the hash can be initialized with a list of key-value pairs. (Remember that (foo => 42, bar => 43 ) is the same as ('foo', 42, 'bar', 43) .
Now, when you use the backslash reference operator in a hash, as in \%fileDetails , you get a hash that is a scalar that points to a hash.
Similarly, if you write \@array , you will get a reference to the array.
But when you use the link operator in a list, you do not get a link to the list (since lists are not variables (they are ephemeral), they cannot be referenced.) Instead, the link operator distributes over the list items, therefore
\( 'foo', 'bar', 'baz' );
creates a new list:
( \'foo', \'bar', \'baz' );
(In this case, we get a list full of scalar links.) And this is what you see when you try to Dumper results of your subroutine: a reference operator distributed over the list of items returned from your sub.
So, one solution is to assign the result list to the actual hash variable before using Dumper. The other is to return a hash link (that you are splitting anyway) from sub:
return \%fileDetails; ... my $details_ref = fileDetailsSub(); print Dumper( $details_ref );
See below for more details.