SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 26th, 2000, 09:56 PM
sEnG sEnG is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: singapore
Posts: 21 sEnG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i need to do a randomisation of an array how do i do it?? i tried the rand() function but it returns some weird numbers with lots of decimal points....
thanks i really need help!!

Reply With Quote
  #2  
Old November 27th, 2000, 04:12 AM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
If I understood you correctly this is what you want. It will print random line from @phrases array:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
# Invoke srand; with a seed of the time and pid. If you are on a machine
# which doesn't put the pid into $$ (ie. Macintosh, Win NT, etc...), change
# this line to: srand(time ^ 22/7);

srand(time ^ $$);

# Now pluck our random phrase out of the @phrases array! But wait! This
# only returns a number.

$phrase = rand(@phrases);

# Print out the Content-type header, so the browser knows what's going on.

print "Content-type: text/htmlnn";

# Change this number into the text we want to return and print it!

print $phrases[$phrase];
[/code]

[This message has been edited by Pepe (edited November 27, 2000).]

[This message has been edited by Pepe (edited November 27, 2000).]

Reply With Quote
  #3  
Old November 28th, 2000, 12:55 AM
sEnG sEnG is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: singapore
Posts: 21 sEnG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks pepe..
u have solved part of my problem...in my case i have to randomise an array of string that i have extracted from my database..what u have written in the above post only get 1 string out from the array. if i use the rand() function that u have taught me, sometimes it will get back the same string from the array again..
anyway thanks for ur help..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Randomisation???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway