Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6119957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:36:47+00:00 2026-05-23T15:36:47+00:00

I am trying to port a piece of code from perl to php. The

  • 0

I am trying to port a piece of code from perl to php. The perl code snippet is part of akamai’s video on demand link generation script. The script generates seed based on the location / URL of the video file (which will always be constant for a single URL). And then it is used in generating serial ID for stream (which is basically a random number between 1 and 2000 using the seed). Here is the perl code.

$seed=6718;
srand($seed);
print(int(rand(1999)) + 1); // return 442 every time

And the converted PHP code is:

$seed=6718;
srand($seed);
echo(rand(0, 1999) + 1); //returns 155 every time

Does php rand behaves differently than perl one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:36:47+00:00Added an answer on May 23, 2026 at 3:36 pm

    Yes. You can’t depend on their algorithms being the same. For perl, which rand is used depends on what platform your perl was built for.

    You may have more luck using a particular algorithm; for instance, Mersenne Twister looks to be available for both PHP and Perl.
    Update: trying it produces different results, so that one at least won’t do the trick.

    Update 2: From the perl numbers you show, your perl is using the drand48 library; I don’t know whether that’s available for PHP at all, and google isn’t helping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to port this piece of code from c++ to c#: ... strPrivateKey
I'm currently trying to port an app from asp.net to php, however I just
Trying to port some old PHP code to Ruby and missing some key info
I am trying to port some C++ code from Windows to Solaris(Unix). There are
I am trying to run this piece of code taken from http://coffeescriptcookbook.com embedding it
Hey, I'm really struggling with this one. I'am trying to port a small piece
I'm trying to port a PHP site developed by another coder (who is no
I am trying to port this algorithm to clojure. My code is (defn calc-iterations
The following piece of code is a reduced sample from the large project I'm
Am trying to write a piece of code which will allows the user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.