Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: generating ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 11025 of 11531
Post > Topic >>

Re: generating number ranges using rand function

by noreply@[EMAIL PROTECTED] (Gunnar Hjalmarsson) May 4, 2008 at 05:54 PM

Aruna Goke wrote:
> I have worked on the code below and am able to generate the 15digit 
> lenght required .
> 
> However, what i wish to achieve is to make sure all the output comes out

> in 15 digits each. a sample of my output is as below.
> 
> Can someone guide on how to make all come out in 15digits.
> 
> Thank you.
> 
> Goksie
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> use Perl6::Say;
> 
> # make a subrouting to generate random numbers;
> my ($ab, $ac, $ad, $a, $b, $c, $d);
> sub pin_number($$$){
> ($b, $c, $d) = @[EMAIL PROTECTED]
> for($a=0; $a<=10; $a++){
> $ab = int(rand($b));
> $ac = int(rand($c));
> $ad = int(rand($d));
> say $ab, $ac, $ad;
> }
> 
>  }
> pin_number(99999,99999,99999);
> 
> _OUTPUT_
> 737027546660830
> 4806662848095
> 88295762678621
> 823446006493218
> 459372786221944
> 897977689470748
> 924616140070650
> 897575667638802
> 269285958818874
> 740564487266857
> 17098933279094

So you want a random number between 100_000_000_000_000 and 
999_999_999_999_999, right? Then why not just follow the example in the 
FAQ entry

     perldoc -q "get a random number"

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 




 6 Posts in Topic:
generating number ranges using rand function
myklass@[EMAIL PROTECTED]  2008-05-04 16:09:53 
Re: generating number ranges using rand function
noreply@[EMAIL PROTECTED]  2008-05-04 17:54:05 
Re: generating number ranges using rand function
Jenda@[EMAIL PROTECTED]   2008-05-04 18:38:43 
Re: generating number ranges using rand function
krahnj@[EMAIL PROTECTED]   2008-05-04 13:43:52 
Re: generating number ranges using rand function
myklass@[EMAIL PROTECTED]  2008-05-04 23:48:28 
Re: generating number ranges using rand function
rob.dixon@[EMAIL PROTECTE  2008-05-05 14:16:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 1:04:58 CDT 2008.