Skip to content

Instantly share code, notes, and snippets.

@wsdookadr
Created October 2, 2011 16:38
Show Gist options
  • Select an option

  • Save wsdookadr/1257610 to your computer and use it in GitHub Desktop.

Select an option

Save wsdookadr/1257610 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Storable qw/dclone/;
use Data::Dumper;
my $a = {
'%h_outside' => {
'a' => 1,
'b' => 2
},
'@a_inside' => [
'x',
'y',
3
],
'$s_inside' => 42,
'$r_inside' => undef,
'$r2_outside' => undef,
'$s_outside' => 42,
'%h_inside' => {
'a' => 1,
'b' => 2
},
'$r2_inside' => $a->{'$r_inside'},
'@a_outside' => [
'x',
'y',
3
],
'$r_outside' => $a->{'$s_outside'},
};
my $b = {
'%h_outside' => {
'a' => 1,
'b' => 2
},
'$r2_outside' => undef,
'$s_outside' => 42,
'@a_outside' => [
'x',
'y',
3
],
'$r_outside' => $a->{'$s_outside'},
};
#######################
# computing complement
#######################
my $b_c = dclone($a) ; # completement of $b with respect to $a
delete $b_c->{$_} for keys %{$b};
print Dumper $b_c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment