Last active
July 31, 2017 12:19
-
-
Save heypano/6498755 to your computer and use it in GitHub Desktop.
Set multiple keys of a hash ref to 1 without a loop
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 warnings; | |
use strict; | |
use Data::Dumper; | |
my %hash = (a => 1, b => 1, c => 1); | |
my $hashref = \%hash; | |
my @keys = ('d','e','f','g','h','i'); | |
@$hashref{@keys}=(1)x(@keys); | |
print Dumper($hashref); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment