Andrew (exstatica) wrote in lj_dev,

Some perl help.

I didn't know where to post cause the LJ_Perl community was really really dead....

I added a modification to LJ codebase. I didn't want to implement Invite codes but i did want them to have to enter some type of randomly generated code that way people with these scripts can't go and register 400 accounts in a matter of a few hours. I made the code show up as an image using GD that way they couldn't copy and paste it. :) haha i thought of it all. Well it works great but for some reason it doesn't keep a set static length of characters. It's completly random. sometimes 3 characters sometime the 8 that i want. i mean i guess it doesnt' matter much but i think it would be nice if it did make it more standard.

This is the Gen code i have...
sub create_code {
my $rcode;
my $_rand;

my $rcode_length = $_[0];
if (!$rcode_length) {
$rcode_length = 8;

my @chars = split(" ",
"A B C D E F G H J K L M N P Q R S T U X Y Z
2 3 4 5 6 7 8 9");


for (my $i=0; $i <= $rcode_length ;$i++) {
$_rand = int(rand 67);
$rcode .= $chars[$_rand];
return $rcode;

anyone who is good with perl can you tell me what i'm doing wrong?

i call it using LJ::create_code(8)

but no luck... see for yourself just keep hitting refresh you will see the random size of it.

Thanks in advanced.


  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded