in reply to Passing a hash byreference to a subroutine

Hello edimusrex,

Well I think you should read this articles why you should pass a ref instead of a hash (Subroutines: Returning a hash vs. hash reference).

After that I think you should read from the Perl CookBook (10.5. Passing Arrays and Hashes by Reference, 2.7.2 Passing References).

Having said that you can pass the hash ref from your example in 3 different ways.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); my $existing_users = { 'user1' => { 'UserName' => 'user1', 'Ignore' => 'N', 'LastAccessDate' => '0000-00-00' }, 'user2' => { 'UserName' => 'user2', 'Ignore' => 'N', 'LastAccessDate' => '0000-00-00' }, }; print Dumper send_to_sub($existing_users); print Dumper send_to_sub_2(\%{$existing_users}); print Dumper send_to_sub_3(\%$existing_users); sub send_to_sub { return @_; } sub send_to_sub_2 { return @_; } sub send_to_sub_3 { return @_; } __END__ $ perl test.pl $VAR1 = { 'user1' => { 'UserName' => 'user1', 'Ignore' => 'N', 'LastAccessDate' => '0000-00-00' }, 'user2' => { 'UserName' => 'user2', 'LastAccessDate' => '0000-00-00', 'Ignore' => 'N' } }; $VAR1 = { 'user1' => { 'UserName' => 'user1', 'Ignore' => 'N', 'LastAccessDate' => '0000-00-00' }, 'user2' => { 'UserName' => 'user2', 'LastAccessDate' => '0000-00-00', 'Ignore' => 'N' } }; $VAR1 = { 'user1' => { 'UserName' => 'user1', 'Ignore' => 'N', 'LastAccessDate' => '0000-00-00' }, 'user2' => { 'UserName' => 'user2', 'LastAccessDate' => '0000-00-00', 'Ignore' => 'N' } };

As you can tell all subroutines return the same result. just different way of defining it.

Update: I think this will also be useful for reading What does my ($data) = @_ mean?.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!