Skip to content

Instantly share code, notes, and snippets.

@gaurav
Created February 15, 2014 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaurav/9014086 to your computer and use it in GitHub Desktop.
Save gaurav/9014086 to your computer and use it in GitHub Desktop.
Demonstrating the logical defined-or operator
#!/usr/bin/perl
use strict;
use warnings;
my $NewUsage = 150;
my %Usage = ();
foreach my $mac ('ABC', 'DEF', 'ABC', 'DEF', 'GHI') {
$Usage{$mac} = $Usage{$mac} // 0;
$Usage{$mac} += $NewUsage;
}
use Data::Dumper;
print Dumper(\%Usage);
__DATA__
$VAR1 = {
'ABC' => 300,
'DEF' => 300,
'GHI' => 150
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment