How do you like my RNG?

#!/usr/bin/perl use warnings; use strict; use Time::HiRes qw ( usleep ); $| = 1; print "number of digits: "; my $num = <STDIN>; chomp $num; if($num < 1){ print "grirrrrr. You can't do that! Number must be 1 or greater!!! +\n"; exit(0); } print randmiz0r($num); sub randmiz0r{ my $digCount = shift; my $digCountChanging = $digCount + 1; #offset for first subtractio +n my $results = ""; for(my $i = 0;$i < $digCount;$i++){ my $randInput = 1 . (0 x ($digCountChanging - 1)); #retreave the last diggit my @prepLastDig = split //, &randmore($randInput); my $lastDig = pop @prepLastDig; $results = $lastDig . $results; #sleep because rand funct is time based usleep( int rand int rand 10000 ); # sleep for microseconds } if($results =~ m/^0/){ $results = catchStartZero($results); #numbers like 0345 don't +exist } return $results . "\n"; } sub randmore{ my $r = shift; my $oddCatch = $r % 2; $r = $r - $oddCatch; return (int (rand $r) + int (rand $r)); } sub catchStartZero{ my $removeZero = shift; $removeZero =~ s/^0//; my $notZero = 0; #confusing but nessisary until($notZero ne "0"){ $notZero = randmiz0r(1); chomp $notZero; #a \n is returned with randmiz0r() } return $notZero . $removeZero; }

In reply to Random Number Generator by perlaintdead

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.