#!/usr/bin/perl
# ABSTRACT: Generate a finite number of results, given a length and type
# PODNAME: bin/Passworder
#
# This script is nearly identical to rndpassword, but allows you to generate a
# finite number of results.

use strict;
use warnings;

use Data::SimplePassword;

# Get desired password length.
my $l = defined $ARGV[0] ? shift : die "Usage: perl $0 length type [num]\n";
# Get the type of char generator to use.
my $t = defined $ARGV[0] ? shift : 'default';
# Get the number of data points desired.
my $n = defined $ARGV[0] ? shift : 9;

# Declare a pw instance.
my $sp = Data::SimplePassword->new;

# Declare the types (lifted directly from rndpassword).
my $chars = {
    default => [ 0..9, 'a'..'z', 'A'..'Z' ],
    ascii   => [ map { sprintf "%c", $_ } 33 .. 126 ],
    base64  => [ 0..9, 'a'..'z', 'A'..'Z', qw(+ /) ],
    b64     => [ 0..9, 'a'..'z', 'A'..'Z', qw(+ /) ],
    simple  => [ 0..9, 'a'..'z' ],
    alpha   => [ 'a'..'z' ],
    digit   => [ 0..9 ],
    binary  => [ 0, 1 ],
    morse   => [ qw(. -) ],
};
# Set the chars based on the given type.
$sp->chars( @{ $chars->{$t} } );

# Roll!
for(0 .. $n) {
    print $sp->make_password($l), "\n";
}

__END__

=pod

=encoding UTF-8

=head1 NAME

bin/Passworder - Generate a finite number of results, given a length and type

=head1 VERSION

version 0.03

=head2 TYPES

  Types     output sample
  default   0xaVbi3O2Lz8E69s  # 0..9 a..z A..Z
  ascii     n:.T<Gr!,e*[k=eu  # visible ascii (a.k.a. spaghetti)
  base64    PC2gb5/8+fBDuw+d  # 0..9 a..z A..Z /+
  simple    xek4imbjcmctsxd3  # 0..9 a..z
  alpha     femvifzscyvvlwvn  # a..z
  digit     7563919623282657  # 0..9
  binary    1001011110000101
  morse     -.--...-.--.-..-

=head1 AUTHOR

Gene Boggs <gene@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Gene Boggs.

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
