Created
May 9, 2022 19:59
-
-
Save wolfjohns/0cc1f3e32a67ee398b76151cf9ededa7 to your computer and use it in GitHub Desktop.
example of perl subroutine taking arguments
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
sub get_latlong_matching_airports { | |
my ($parm1, $parm2, $parm3, $parm4) = @_; | |
my %args = ( | |
airports => $parm1, | |
lat => $parm2, | |
long => $parm3, | |
max => $parm4, | |
# @_ # this I was not sure of how it worked in the subroutine with defined keys but undefined values | |
); | |
But if I understand what you are saying then | |
sub get_latlong_matching_airports { | |
my %args = ( | |
airports => undef, | |
lat => undef, | |
long => undef, | |
max => undef, | |
@_ | |
); # then something like get_latlong_matching_airports('Gatwick', 52.40, 1.07, 30) would be slurped by @_ at the bottom | |
of the subroutine get_latlong_matching_airports and become the values to the keys | |
so that | |
airports => 'Gatwick', | |
lat => 52.40, | |
long => 1.07, | |
max => 30, | |
would be the result of the values passed by @_ at the bottom of the hash %args? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment