Created
March 28, 2022 14:44
-
-
Save wolfjohns/fee1bf921011b5fb8c523a47874b053e to your computer and use it in GitHub Desktop.
geekuni Topic 7 q10
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 Data::Dump 'pp'; | |
use feature 'say'; | |
use Getopt::Long; | |
use Text::CSV qw(csv); | |
#### | |
#FILL ME IN!! | |
sub parse_airports { | |
my $filename = shift; | |
my $airports = csv( | |
in => $filename, | |
headers => 'auto'); | |
return $airports; | |
} | |
my $filename = '/home/student/perl-basic/topic-07/iata_airports.csv'; | |
my $number = 1; | |
my $matching; | |
my $latitude; | |
my $longitude; | |
GetOptions ( | |
'filename:s' => \$filename, | |
'number:i' => \$number, | |
'matching:s' => \$matching, | |
'latitude:f' => \$latitude, | |
'longitude:f' => \$longitude, | |
) or die "Invalid options passed $0\n"; | |
#### | |
my $rah_airports = parse_airports($filename); | |
my $rah_airports_found = []; | |
if ($matching) { | |
say "Up to $number airports matching $matching in $filename:"; | |
} | |
elsif ($latitude && $longitude) { | |
say "Up to $number airports near [$latitude, $longitude] in $filename:" | |
} | |
else { | |
say "Must have at least --matching, or --latitude and --longitude as arguments"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment