magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1996 > 12 > Programming with Perl  

Something Random This Way Comes

Sure, there are random link scripts and random "quote-of-the-day" scripts out there. But I wanted to tackle the subject and give it a twist—some memory. The random program I'll describe here "knows" what random items have been given out recently, and biases older items with a higher probability of being selected. My random program does it in a way that allows a large number of entries to run in parallel, not tying up a central database while making a decision. "Cool," you say? Read on!

Not only that, the program could be easily used for random links, random ads (bleh, but they pay the bills for the coolest free sites), or even just random graphics. So how much would you pay? It's free, and can be found in Listing One. Much of it is commented, but let me hit the high points.

Random Thoughts

The first two lines in Listing One begin nearly every program I write these days. Line 1 enables taint checks and warnings, while line 2 forces me to think about the variables I am using and why. Line 3 brings in a neat utility module that I use to get the directory part (dirname) and file part (basename) of some of the UNIX paths and URLs.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2