MAC vendor lookup: Difference between revisions
→{{header|Perl 6}}: Add a Perl 6 example
(→{{header|zkl}}: added test) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add a Perl 6 example) |
||
Line 78:
}
</lang>
=={{header|Perl 6}}==
{{works with|Rakudo|2016.12}}
<lang perl6>use HTTP::UserAgent;
my $ua = HTTP::UserAgent.new;
$ua.timeout = 10; # seconds
my $server = 'http://api.macvendors.com/';
sub lookup ($mac) {
my $response = $ua.get: "$server+$mac";
return $response.is-success ?? $response.content !! 'N/A';
CATCH { # Normally you would report some information about what
default { Nil } # went wrong, but the task specifies to ignore errors.
}
}
for <
BC:5F:F4
FC-A1-3E
10:dd:b1
00,0d,4b
23:45:67
> -> $mac { say lookup $mac }</lang>
{{out}}
<pre>ASRock Incorporation
Samsung Electronics Co.,Ltd
Apple, Inc.
Roku, Inc.
N/A
</pre>
=={{header|zkl}}==
|