Skip to content

Instantly share code, notes, and snippets.

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 wolfjohns/0cc1f3e32a67ee398b76151cf9ededa7 to your computer and use it in GitHub Desktop.
Save wolfjohns/0cc1f3e32a67ee398b76151cf9ededa7 to your computer and use it in GitHub Desktop.
example of perl subroutine taking arguments
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