Amazon-SQS-Client

 view release on metacpan or  search on metacpan

share/example.pl  view on Meta::CPAN

#!/usr/bin/env perl

# Script for exercising Amazon::SQS examples.

use strict;
use warnings;

use Amazon::SQS::Sample;
use Data::Dumper;
use English qw(-no_match_vars);
use Carp qw(carp croak);
use Pod::Usage;
use Module::Load qw(load);

use Getopt::Long qw(:config no_ignore_case);

########################################################################
sub main {
########################################################################
  my %options;

  my @option_specs = qw(
    file|f=s
    help|h
    endpoint-url|e=s
    debug|d
  );

  my $retval = GetOptions( \%options, @option_specs );

  if ( !$retval || ( $options{help} && !@ARGV ) ) {
    pod2usage(1);
  }

  my $example = shift @ARGV;

  load $example;

  my $sample = $example->new( \%options );

  if ( $options{help} ) {
    $sample->help();
  }

  eval { $sample->sample(@ARGV); };

  $sample->check_error($EVAL_ERROR);

  return 0
    if !$options{debug};

  print {*STDERR} Dumper(
    [ request     => $sample->get_service->get_last_request,
      response    => $sample->get_service->get_last_response,
      credentials => $sample->get_service->get_credentials,
    ]
  );

  return 0;
}

exit main();

1;

## no critic

__END__



( run in 1.151 second using v1.01-cache-2.11-cpan-39bf76dae61 )