Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Tagline Rotator

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


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found