Gossamer Forum
Home : General : Perl Programming :

Why doesn't this work?

Quote Reply
Why doesn't this work?
here is the script:
Code:
#!/usr/bin/perl

# user value arguments
$uservalue = $ARGV[0];

printf(" $uservalue \n");
$code = 183654729;
for ($n=0; $n < length($uservalue); $n++)
{
$code *= $uservalue[$n];
$code %= 100000000;
}
printf( " $code \n");

The code it always returns is 0. How come? thanks.

------------------
Quote Reply
Re: Why doesn't this work? In reply to
You should use strict and you'd see that you are trying to access @uservalue as an array, when in fact you only have a string $uservalue. Perhaps you want to add:

@uservalue = split //, $uservalue;

Cheers,

Alex
Quote Reply
Re: Why doesn't this work? In reply to
No luck. This script is supposed to create a key based on the username. so if I called the script, test.cgi

test.cgi?Nicholas Clark

$uservalue=Nicholas Clark

Someone else who I am trying to get this to work for syas that an ascii value should be assigned to each character so that a number results. any ideas?

------------------
Quote Reply
Re: Why doesn't this work? In reply to
CEGlobe,

I don't think you can call your script like this:

Code:
test.cgi?Nicholas Clark

$uservalue=Nicholas Clark

Because it contains spaces. Try this:

Code:
test.cgi?Nicholas_Clark

$uservalue=Nicholas_Clark


Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: Why doesn't this work? In reply to
That's not important right now. Even if I enter test.cgi?name , the value returned for the code is always 0. How come?

------------------