#!perl

use strict;
use warnings;
use 5.022;
#use lib::findbin '../lib'; # dev-only
use Pod::Simple::Words;

# PODNAME: pod2yamlwords
# DESCRIPTION: Dump words from POD as YAML
our $VERSION = '0.07'; # VERSION

my $name = shift @ARGV;
unless(defined $name)
{
  say STDERR "usage: $0 pod\n";
  exit 1;
}

my $filename;
if(-f $name)
{
  $filename = $name;
}
else
{
  my $path = join('/', split /::/, $name) . ".pm";
  foreach my $try (map { join '/', $_, $path } @INC)
  {
    if(-f $try)
    {
      $filename = $try;
      last;
    }
  }
}

unless(defined $filename)
{
  say STDERR "no file found for $name";
  exit 2;
}

unless(-f $filename && -r $filename)
{
  say STDERR "bad or unreadable file $filename";
  exit 2;
}


my $parser = Pod::Simple::Words->new;
$parser->parse_file($filename);

__END__

=pod

=encoding UTF-8

=head1 NAME

pod2yamlwords

=head1 VERSION

version 0.07

=head1 AUTHOR

Graham Ollis <plicease@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
