Recent Articles

Bouncing Around Perl On The Web
Once you have trounced the rest of the Perl class in Prisoner's Dilemma and are ready to take your skills into the field, it's good to know plenty of resources exist online. The drumbeat of PHP, Java, and Rails has...

Stripping Out Bad Characters Generated By A Perl...
There is an interesting thread in the WebProWorld forum that solves a problem a member was having trying to strip bad characters from a block of text generated...

ColdFusion Brands With Adobe, Shares Data with Perl
ColdFusion's latest version emerges for the first time under the Adobe brand name; it's changed a lot since its early dot-com days of doing database calls for HTML. The arrival of the public beta of Adobe ColdFusion 8...

How to Make your URLs SEO Friendly
It is a well-known fact nowadays that without SEO a Web site stands many chances of not being indexed by search spiders, therefore risking not being ranked high...

Apache, PHP, Suhosin Security Patch and mod_perl
For many reasons many people want to compile their own source code to build apache and php / mod_perl these days. We will discuss the steps required in doing just that. But unlike most others we will throw in some...

Review: The Apache Module Book
Aaargh.. C code. I never thought I'd say that, but there it is. I must be getting old. Oh well, at least I can still read it. And this book did open my eyes to the inner...


11.16.07


Random Subroutines In Perl

By A.P. Lawrence

I'll bet your first question might be "why on earth would I ever want to call subroutines randomly?".

Admittedly, it isn't a need that comes up that often, but (for example) it's used right here on this very page that you are reading.

Ayup, you guessed it, it's ads again. I know, I know: you hate the ads, but they pay the bills, and actually every now and then there's something that actually might be of interest, so there it is and there they are. If you need to see the page without ads, disabling Javascript will get rid of a lot of them, and clicking on the "Printer Friendly" link will absolutely remove them all.

OK, now that you've accepted the inevitable, let's look at things from the publisher's point of view. We have various ads to run, and places to run them. What runs where? Well, duh, you put the best performing ads first. OK, then what? Second best? Sure, but what happens when you don't know what works best? Like right about to the left of this paragraph, what works best there?

Or maybe I just want them random to help combat that awful "ad blindness" that comes from people seeing the the same thing in the same place and therefor not really seeing it at all. Maybe mixing things up will help.

Whatever the reason, I have a choice of three or four ads I could stick over there, but I'm not sure which I want first. Maybe I want random Perl subroutines?

Try a Better Way Today. Try WebEx PCNow

Why subroutines rather than just variables containing the text of the various ads? Well, you could do it that way, but subroutines seem cleaner to me. It comes down to doing something like this:



I think the first form (an anonymous subroutine) is neater and less confusing to modify. So let's use that. This example defines a few anonymous subroutines and then runs through them randomly:

Continue reading this article.

About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com


About PerlProNews
PerlProNews is a collection of news and commentary designed to keep you in step with the ever evolving landscape of Perl environments. News and Advice for Perl Professionals

PerlProNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
PerlProNews.com SQLProNews.com
SysAdminNews DevWebPro.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITCertificationNews.com


-- PerlProNews
is an iEntry, Inc. publication --
iEntry, 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article



Database Forum News and Advice for Perl Professionals PerlProNews News Archives About Us Feedback PerlProNews.com About Article Archive News Downloads WebProWorld Forums iEntry Advertise Contact Jayde