#!/usr/bin/perl
# ABSTRACT: Generate a range of sequential or random integer or floating point numbers
# PODNAME: bin/Number-Ranger

use strict;
use warnings;

# Get start and end numbers.
my $i = defined $ARGV[0] ? shift : die "Usage: perl $0 start end [prec rand num]\n";
my $j = defined $ARGV[0] ? shift : 9;
# Get the decimal precision.
my $p = defined $ARGV[0] ? shift : 2;
# Do we want random numbers?
my $r = defined $ARGV[0] ? shift : 0;
# Get the number of data points desired.
my $n = defined $ARGV[0] ? shift : 9;

# Do we want random numbers?
if ($r) {
    # Roll!
    for(0 .. $n) {
        # Get our random candidate.
        my $x = rand($j);
        # Make sure it is above the start value.
        while ($x < $i) {
            $x = rand($j);
        }
        printf "%.*f\n", $p, $x;
    }
}
else {
    # Print a sequence of integers.
    print join("\n", map { sprintf('%d', $_) } $i .. $j);
}

__END__

=pod

=encoding UTF-8

=head1 NAME

bin/Number-Ranger - Generate a range of sequential or random integer or floating point numbers

=head1 VERSION

version 0.03

=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
