Created
February 15, 2014 03:19
-
-
Save gaurav/9014086 to your computer and use it in GitHub Desktop.
Demonstrating the logical defined-or operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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