Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl: the Markov chain saw
 
PerlMonks  

Re: Tagline Rotator

by Daddio (Chaplain)
on May 29, 2001 at 03:46 UTC ( [id://83830]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Tagline Rotator

cajun, I think this is a great script. It's simple and straightforward.

I would like to point out a couple of things that I think would help.

First, I might recommend putting the open(OUTFILE,...) and close OUTFILE into the same else section as the print OUTFILE @body. There's no sense opening and closing a file if you don't need to in debug mode (and it will erase whatever is there if you are in debug mode - no sense doing that, either).

Second, and more importantly, the sprintf("%.0f", ($rand) code may return a 0. To counter that, I would recommend these two changes:

One, change

my $rand=$rand($.);

to

my $rand = 0; $rand = int rand($.) until $rand != 0;

Two, change

push (@body, qq(  $hash{sprintf("%.0f", ($rand))}));

to

push (@body, qq(  $hash{$rand}));

Hope this makes sense (it's been a long day :)!

D a d d i o

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://83830]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.