Last active
July 8, 2017 00:17
-
-
Save swelljoe/133c6e6cf3928f6e419bb3f58e27adc7 to your computer and use it in GitHub Desktop.
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; | |
use 5.010; | |
my $extrakey = "doot"; | |
my $extraval = "toot"; | |
my %hash = ( | |
name => 'Joe', | |
age => 'Grumpy', | |
); | |
sub myFunction { | |
my %hash = @_; | |
say $hash{name}; | |
say $hash{doot}; | |
say $hash{age}; | |
} | |
myFunction($extrakey, $extraval, %hash); | |
# This prints: | |
# Joe | |
# toot | |
# Grumpy | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Everything gets flattened as it comes into the function.
Refs are the way to avoid that flattening (because a ref just points to data, it isn't the data so there's nothing to flatten), if you need to pass in complex data structures.