Hashes pt. 2

Let's take a hash

my %content = ( username => $ref->{username}, email => $ref->{email} );

Send a reference to the hash, along with other parameters, to some function

someFunc(\%content, $title);

Then unpack it at the other end

sub someFunc {
  my ($contentRef, $title)=@_;
  my %content = %$contentRef;
  print $contentRef{username};
}
1;

Posted 23 Aug 2007, tagged with perl