Skip to content

Instantly share code, notes, and snippets.

@msztolcman
Created May 2, 2013 09:38
Show Gist options
  • Save msztolcman/5501210 to your computer and use it in GitHub Desktop.
Save msztolcman/5501210 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 1;
$Data::Dumper::Quotekeys = 1;
sub dmp { say &Dumper; };
my $t = TestHash->new ();
$$t{w} = 2;
dmp ($t, {%$t});
package TestHash;
{
use overload
'%{}' => 'to_hash',
fallback => 1;
sub to_hash {
my ($self, ) = @_;
return $$self[0];
}
sub new {
my $self = [{ q => 1, }];
return bless $self, $_[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment