Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl From Hell 1

Status
Not open for further replies.

BenRussell

Programmer
Mar 12, 2001
243
US
I am having serious problems with one of my scripts.
is the script im having problems with.
is the source code.
I can not figure out why it is displaying $SelectedAd as some weird sequence of numbers (like 0.908109799879).

I can find NOTHING wrong with the script. I have tried this on 3 different servers and it does the same thing every time. Please help.

The problem might be in Essentials.lib (which you can see at but I dont think so. - Ben Russell
- President of Intracor Technologies (
 
Now it's not even displaying anything except some weird HTML and is printing out the MIME content line. But $SelectedAd is being set to a weird value also. - Ben Russell
- President of Intracor Technologies (
 
What is the aim of the script?

Looking at it I can spot a few potential problems but need to know what you're trying to do. Also, what is in $Path_Script/Accounts/ and /$Ad?

Thanks,

Tiz --
Tim <tim@planetedge.co.uk>
 
um,
$SelectedAd = rand (@AdAccounts);
will make $SelectedAd a random fractional number between 0 and the value of @AdAccounts(it's length). what do you want the number to be? an integer? if so, put the whole thing in parentheses and put the word 'int' in front of those parentheses. otherwise, you'll have to say more specifically what you want it to be... &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
First questions first :
$Ad is a scalar I assigned in the foreach statement
$Path_Script/Accounts is the path to the directory called &quot;Accounts&quot; which contains the ad accounts

Which brings me to my next point. The point of the script is to read files, get their information (the information gives a file URL and a URL to point to) to display a random ad (sort of like WebAdverts)

I thought the $SelectedAd = rand (@AdAccounts) would assign $SelectedAd a random value in @AdAccounts (so that a random ad would be displayed) - Ben Russell
- President of Intracor Technologies (
 
Try:
Code:
$SelectedAd = $AdAccounts[int(rand $#AdAccounts)];
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I can't tell what else might be wrong looking at the code from the link you originally posted. Are you sure that the path variable is set correctly?
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top