CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Post deleted by psr

 



psr
Novice

Apr 6, 2013, 9:08 PM

Post #1 of 2 (349 views)
Post deleted by psr

 


g4143
Novice

Apr 7, 2013, 1:50 PM

Post #2 of 2 (330 views)
Re: [psr] quick help with random number generator [In reply to] Can't Post

I think you have to understand that array's in Perl start at element 0. Try looking at the code below.


Code
#!/usr/bin/perl 

use warnings;
use strict;

my @arr = ();
my $range = 10;

foreach ( 1..10 )
{

print "\nLoop count->$_\n";

my $size = int(rand($range));
print "Array size->$size\n";

foreach (0..($size - 1))
{
$arr[$_] = $_;
}

foreach (0..($size - 1))
{
print "array element $_ has a value-> $arr[$_]\n";
}
}

__END__


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives