Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created July 17, 2012 08:33
Show Gist options
  • Save ynonp/3128048 to your computer and use it in GitHub Desktop.
Save ynonp/3128048 to your computer and use it in GitHub Desktop.
use v5.14;
use List::Util qw/sum/;
sub add_to_hash {
my ( $hash_ref, $key, $value ) = @_;
$hash_ref->{$key} = $value;
}
sub diff_sum {
my ( $x_ref, $y_ref ) = @_;
my $sum_x = sum ( @$x_ref );
my $sum_y = sum ( @$y_ref );
return $sum_x - $sum_y;
}
my @a = (1, 2, 5);
my @b = (5, 5);
my $ds = diff_sum( \@a, \@b );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment