Results 1 to 4 of 4

Thread: porting php rand() to perl

  1. #1
    Join Date
    Dec 2008
    Posts
    48
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default porting php rand() to perl

    hello, i am trying to modify a perl script but i really only know php lol

    how would i go about on doing rand(10,19); on perl?

    i tried all combinations i could think of but cant get it to work

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try:
    Code:
    print int(rand(9))+10;
    Just find the range of the numbers (by subtracting), and add the minimum. In php:
    Code:
    echo rand(0, 9) + 10;
    It's the same basics.
    Range: 19-10 = 9
    Minimum: 10
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    nicmo (03-31-2010)

  4. #3
    Join Date
    Dec 2008
    Posts
    48
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    clever lol, thanks mate.

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No problem, glad to help.

    It seems your topic is solved... Please set the status to resolved.. To do this:
    Go to your first post ->
    Edit your first post ->
    Click "Go Advanced" ->
    Then in the drop down next to the title, select "RESOLVED"
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •