NAME

Parse::SAMGov - Parses SAM Entity Management Public Extract Layout from SAM.gov

VERSION

version 0.201

SYNOPSIS

my $parser = Parse::SAMGov->new;
my $entities = $parser->parse_file('SAM_PUBLIC_DAILY_20160701.dat');
foreach my $e (@$entities) {
    ## do something with each entity
    say $e->DUNS, ' is a valid entity';
}
#... use in filter mode like grep ...
my $entities_541511 = $parser->parse_file('SAM_PUBLIC_DAILY_20160701.dat',
                                sub {
                                    # filter all companies with NAICS code
                                    # being 541511
                                    return $_[0] if exists $_[0]->NAICS->{541511};
                                    return undef;
                                });

# ... do something ...
my $exclusions = $parser->parse_file(exclusion => 'SAM_Exclusions_Public_Extract_16202.CSV');
foreach my $e (@$exclusions) {
    ## do something with each entity that has been excluded
    say $e->DUNS, ' has been excluded';
}

METHODS

parse_file

This method takes as arguments the file to be parsed and returns an array reference of Parse::SAMGov::Entity or Parse::SAMGOv::Exclusion objects depending on the data being parsed.

If the second argument is a coderef then passes each Entity or Exclusion object into the callback where the user can select which objects they want to return. The user has to return 1 if they want the object returned in the array ref or undef if they do not.

my $entities = $parser->parse_file('SAM_PUBLIC_DAILY_20160701.dat');
my $exclusions = $parser->parse_file('SAM_Exclusions_Public_Extract_16202.CSV');
my $entities = $parser->parse_file('SAM_PUBLIC_DAILY_20160701.dat', sub {
    my ($entity_or_exclusion, $optional_user_arg) = @_;
    #... do something ...
    return 1 if (!$entity_or_exclusion->is_private);
    return undef;
}, $optional_user_arg);

SEE ALSO

Parse::SAMGov::Entity and Parse::SAMGov::Exclusion for the object definitions.

AUTHOR

Vikas N Kumar <vikas@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Selective Intellect LLC.

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