The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
#
# test script for proving external command for fetching tags works
#
use strict;
use warnings;
use Getopt::Std;

my $opt = {};
getopts( 'Lqx', $opt );

my %tag_lookup = (
    tag100 => [qw/ host100 /],
    tag200 => [qw/ host200 host210 host205 /],
    tag300 => [qw/ host300 host350 host325 /],
    tag400 => [qw/ tag100 tag200 tag300 host400 host401 /],
);

# if we get '-q' option, force an error
if ( $opt->{q} ) {
    my $fail;
    $fail->cause_death();
}

# if we get '-x' option, die with non-0 return code
if ( $opt->{x} ) {
    warn 'Forced non-0 exit', $/;
    exit 5;
}

# '-L' means list out available tags
if ( $opt->{L} ) {
    print join(' ', sort keys %tag_lookup), $/;
    exit 0;
}

my @lookup = @ARGV;

for (@lookup) {
    if ( $tag_lookup{$_} ) {
        push( @lookup, @{ $tag_lookup{$_} } );
        $_ = '';
    }
}

@lookup = grep { $_ !~ m/^$/ } sort @lookup;

if (@lookup) {
    print "@lookup", $/;
}