Solved

convert VB to PERL

Posted on 2002-03-12
34
296 Views
Last Modified: 2008-03-17
Hi, i need the following visual basic function converted to perl. Thanks



Public Function GenerateSerialNumber(FullName As String, UniqueID As String) As String
retry:
Randomize
randkey = Int(Rnd * 99 + 1)
If Len(randkey) < 2 Then
    GoTo retry:
End If
serial = randkey & "-"
For X1 = 1 To Len(FullName) Step 3
    j = Mid(FullName, X1, 1)
    p = p & Int(Asc(j) + randkey - 9 / 2 ^ Int(Mid(randkey, 1, 1)))
    If Len(p) > 6 Then
        Exit For
    End If
Next X1
For X2 = 1 To Len(UniqueID) Step 2
    jx = Mid(UniqueID, X2, 1)
    If IsNumeric(jx) = True Then
        jf = jf & Int(jx * randkey / 2 ^ Int(Mid(randkey, 1, 1)) / 3 * randkey)
    Else
        jf = jf & Int(randkey * Mid(Asc(jx), 1, 1) / 2 ^ Int(Mid(randkey, 1, 1)))
    End If
Next X2
serial = serial & p & "-" & jf
GenerateSerialNumber = serial
End Function
0
Comment
Question by:BrianGEFF719
  • 18
  • 13
  • 2
  • +1
34 Comments
 
LVL 16

Expert Comment

by:maneshr
ID: 6859492
BrianGEFF719,

"., i need the following visual basic function converted to perl. .."

Can you explain, in plain english, what exactly you are looking for?

This will dramatically increase your choice of getting a working solution, faster.

Let me know.
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6859749
I'm going to move this to the VB Section.
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6859768
He wants to generate serial number based upon

Full name and Uniqueid which would be passed to the function.

Is it like you want only this logic to be implemented ???

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6859770
dkjariwala,
That is exactly what i need the perl function to do. All I need is that same function but written in perl. Like he said, I need a perl function to generate serial numbers based upon (name and unique computer id).

If anyone has any questions on this, just let me know.
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6859907
I have just tried,
I don't know if this is perfect or not.

$number= &generate_serial_number('DivyeshJariwala',23423423423);
print $number;



sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.

     my $serial = $randkey . "-";

     my $p_value;

     @array = split(//, $fullname);
     for($i=0;$i<length($fullname);$i+=3)
     {
          $j = substr($fullname,$i,1);
          $power = substr($randkey,1,1);

          $temp = int ( ord($j)  + $randkey - 9 / (  2 ^ $power ) );
          $p .= $temp;
          if(  length($p) > 6 )
          {
               $p_value = $p;
          }
     }
     
     for($i=0;$i<length($uniqueid);$i+=2)
     {
          $jx = substr($uniqueid,$i,1);
          if(!($jx =~ /\D/ ))
          {
               $power = int substr($randkey,1,1);
               $jf .=  int (  ( $jx * $randkey / 2 ^ $power ) / 3 * $randkey );
          }
          else
          {
               $power = int substr($randkey,1,1);
               $jf .= int ( ( $randkey * substr(ord($jx),1,1) ) / 2 ^ $power );

          }
     }
         

     $serial .= $p . '-' . $jf;
     return $serial;
}


JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6859959
i'm going to test this, give me a few min...i'm going to compare outputs with the vb program, and if they are the same output, i will give you points if not ill try to see where the differences are, and tell you because i've got no clue on perl programming


THANKS A LOT FOR YOUR HELP SO FAR!!!!
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6859983
One thing I would like to tell you that it would give you random serial number everytime cause you are utilizing rand function.

So I don't think you can compare them straight off.

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6859988
i'm going to test this, give me a few min...i'm going to compare outputs with the vb program, and if they are the same output, i will give you points if not ill try to see where the differences are, and tell you because i've got no clue on perl programming


THANKS A LOT FOR YOUR HELP SO FAR!!!!
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6859995
yah i can compare, i just generate the serial again but specify the randkey...it will generate the same, but right now i'm getting different serials when i generate...lemme generate some serials for you using the vb function, cuz i've played with it and i can figure out why its generating different...

name: Brian Gaffie
unique id: 51345561

here is a list of some serials that the vb function generated...to test your self just set the randkey. But i dont know perl if i did i would test it my self. The first two digits are the randkey. Thanks!

95-160191165-29172935
43-108139113-192115192231
56-121152126-16398163196
65-130161135-11066110132
61-126157131-965896116
62-127158132-10060100120
31-95126100-200120200240
11-7210377-10060100121
76-141172146-75457590
30-9412599-187112187225
42-107138112-183110183220
38-102133107-300180300361
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860017
No they are not same. :(

Tell me about,

p = p & Int(Asc(j) + randkey - 9 / 2 ^ Int(Mid(randkey, 1, 1)))
   

What is the order of precedance here ??


Similarly for

If IsNumeric(jx) = True Then
       jf = jf & Int(jx * randkey / 2 ^ Int(Mid(randkey, 1, 1)) / 3 * randkey)
   Else
       jf = jf & Int(randkey * Mid(Asc(jx), 1, 1) / 2 ^ Int(Mid(randkey, 1, 1)))
   End If

Both the JF statements,
JD

0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860026
acctually i must say now that you have brought the second part to my attention the part that is IsNumeric, the Unique ID will alawys be numeric so you can remove the else statement...I dont know why i did it taht way when i wrote it.

But I honestly dont know...because i tried converting this to JavaScript and i had some problems...So i dont know why it does this..
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860037
Here is modified code,
I am not sure about your statements for value of P and JF.

Which should be divided by what ?
JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860044
i'm going to try to break it down in the vb function instead of one big math line i'm going to break it down to a bunch of small ones...
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860048
Check this,

I guess you should now find it more comfortable to follow.

$number= &generate_serial_number('Brian Gaffie',51345561);
print $number . "\n";
print '95-160191165-29172935';

sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.


     #################### for testing
     $randkey = 95;
     ################## you override whatever is generated !!

     my $serial = $randkey . "-";

     my $p_value;

     for($i=1;$i<=length($fullname);$i+=3)
     {
          #j = Mid(FullName, X1, 1)
          $j = substr($fullname,$i,1);

             
      #   p = p & Int(Asc(j) + randkey - 9 / 2 ^ Int(Mid(randkey, 1, 1)))

          $power = int substr($randkey,1,1);
          $p .= int ( ord($j)  + $randkey -  9 /  2 ^ $power   );

          if(length($p) > 6 )
          {
               $p_value = $p;
          }
     }
     

     for($i=1;$i<=length($uniqueid);$i+=2)
     {
     #   jx = Mid(UniqueID, X2, 1)
          $jx = substr($uniqueid,$i,1);

          #jf = jf & Int(jx * randkey / 2 ^ Int(Mid(randkey, 1, 1)) / 3 * randkey)
          $power = int(substr($randkey,1,1));
          $jf .=  int (   $jx * $randkey / 2 ^ $power  / 3 * $randkey );
     }
         

     $serial .= $p_value . '-' . $jf;
     return $serial;
}

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860054
hi, I was able to break it down like this, may this will help you.

    xx1 = Asc(j) 'get the ascii value of j
    xx2 = randkey 'set xx2 to randkey
    xx3 = 9 'subtract 9
    xx4 = 2 'divide by 2
    xx5 = Int(Mid(randkey, 1, 1)) 'get the first NUMBER in randkey
    mthfunc = xx1 + xx2 - xx3 / xx4 ^ xx5 'do the math
    mth = Int(mthfunc) 'int
    p = p & mth 'APPEND NUMBER TO P, NOT ADD NUMBER
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860058
I dont know how perl works, but in my visual basic program...P IS A STRING not a INTEGER, here is an idea...may perl is handling P as an INTEGER and trying to add it instead of appending the new number to P.

-Brian
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860065
I think i got it..in Visual Basic strings work like this..

12345
FFFFF

in perl

01234
FFFFF

in perl strings start at 0...not 1. So that could be the problem, if the randkey is 95, it should be doing ^ 9 instead of ^ 5...tell me if that fixes it?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860073
Still it doesnt work. :(

$number= &generate_serial_number('Brian Gaffie',51345561);
print $number . "\n";
print '95-160191165-29172935';

sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.


     #################### for testing
     $randkey = 95;
     ################## you override whatever is generated !!

     my $serial = $randkey . "-";

     my $p_value;

     for($i=1;$i<=length($fullname);$i+=3)
     {
          #j = Mid(FullName, X1, 1)
          $j = substr($fullname,$i,1);
      #   p = p & Int(Asc(j) + randkey - 9 / 2 ^ Int(Mid(randkey, 1, 1)))


        $xx1 = ord(j);                    #         xx1 = Asc(j) 'get the ascii value of j

        $xx2 = $randkey;               ####     xx2 = randkey 'set xx2 to randkey
        $xx3 = 9;                              ####        xx3 = 9 'subtract 9
        $xx4 = 2;                              ####        xx4 = 2 'divide by 2
        $xx5 = int(substr($randkey,1,1)) ; ####        xx5 = Int(Mid(randkey, 1, 1)) 'get the first NUMBER in randkey
        $mthfunc = $xx1 + $xx2 - $xx3 / $xx4 ^ $xx5; ##        mthfunc = xx1 + xx2 - xx3 / xx4 ^ xx5 'do the math

        ####### I want to know what is the order ?? shall i power xx4 by xx5 and divide it by xx3 and then substract it from $xx1 + $xx2 ?
        #### How it shall be done ???
       $mth  = int($mthfunc);    ###mth = Int(mthfunc) 'int
         
          $p .= $mth; ###   p = p & mth 'APPEND NUMBER TO P, NOT ADD NUMBER
          if(length($p) > 6)
          {
               $p_value =$p;
          }


     }
     

     for($i=1;$i<=length($uniqueid);$i+=2)
     {
     #   jx = Mid(UniqueID, X2, 1)
          $jx = substr($uniqueid,$i,1);

          #jf = jf & Int(jx * randkey / 2 ^ Int(Mid(randkey, 1, 1)) / 3 * randkey)
          $power = int(substr($randkey,1,1));
          $jf .=  int (   $jx * $randkey / 2 ^ $power  / 3 * $randkey );
     }
         

     $serial .= $p_value . '-' . $jf;
     return $serial;
}

And I do not understand what you mean to say about those string handling in Perl and VB.

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860076
k let me explain..

mid(string,start,length) <-- VB
substr(string,start,length) <-- PERL

if you wanted to get the first charecter in name the start in vb would be 1, but the start in perl is 0....isnt that correct?

lemme show you:

name = "Brian"
msgbox mid(name,1,1) <--- WILL MESSAGE BOX "B"

but in perl, substr($name,1,1) will do "r"...because it starts at 0

thats what i mean..
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860098
this also works...

xx1 = Asc(j) + randkey
xx5 = Int(Mid(randkey, 1, 1))
mthfunc = xx1 - 9 / 2 ^ xx5
p = p & Int(mthfunc)
   
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860101
Oh, yes,You are very much right.

I did the change, Also I found one bug, corrected it up. but still not working.

$number= &generate_serial_number('Brian Gaffie',51345561);
print $number . "\n";
print '95-160191165-29172935';

sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.


     #################### for testing
     $randkey = 95;
     ################## you override whatever is generated !!

     my $serial = $randkey . "-";

     my $p_value;

     $found = 0;
     for($i=0;$i<length($fullname);$i+=3)
     {
          #j = Mid(FullName, X1, 1)
          $j = substr($fullname,$i,1);

        $xx1 = ord(j);                    #         xx1 = Asc(j) 'get the ascii value of j

        $xx2 = $randkey;               ####     xx2 = randkey 'set xx2 to randkey
        $xx3 = 9;                              ####        xx3 = 9 'subtract 9
        $xx4 = 2;                              ####        xx4 = 2 'divide by 2
        $xx5 = int(substr($randkey,0,1)) ; ####        xx5 = Int(Mid(randkey, 1, 1)) 'get the first NUMBER in randkey
        $mthfunc = $xx1 + $xx2 - $xx3 / $xx4 ^ $xx5; ##        mthfunc = xx1 + xx2 - xx3 / xx4 ^ xx5 'do the math

        ####### I want to know what is the order ?? shall i power xx4 by xx5 and divide it by xx3 and then substract it from $xx1 + $xx2 ?
        #### How it shall be done ???
       $mth  = int($mthfunc);    ###mth = Int(mthfunc) 'int
         
          $p .= $mth; ###   p = p & mth 'APPEND NUMBER TO P, NOT ADD NUMBER
          if(length($p) > 6 and ! $found)
          {
               $p_value =$p;
               $found = 1;
          }


     }
     

     for($i=1;$i<=length($uniqueid);$i+=2)
     {
     #   jx = Mid(UniqueID, X2, 1)
          $jx = substr($uniqueid,$i,1);

          #jf = jf & Int(jx * randkey / 2 ^ Int(Mid(randkey, 1, 1)) / 3 * randkey)
          $power = int(substr($randkey,1,1));
          $jf .=  int (   $jx * $randkey / 2 ^ $power  / 3 * $randkey );
     }
         

     $serial .= $p_value . '-' . $jf;
     return $serial;
}


JD

Can you answer that ordering of xx1,xx2 and stuff , see my comment in code.
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860140
Honestly, I cannot answer the ordering of xx1 and xx2. When i wrote that i just did a bunch of random math things...I've got no clue how VB is processing it.
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860152
Hm...
Actually I am sure that this is where the problem is.

Can you just try to put up braces in VB program and see how it changes the output.

I mean try

p = p & Int(Asc(j) + ( randkey - 9 )/ 2 ^ Int(Mid(randkey, 1, 1)))

or

p = p & Int(Asc(j) + randkey -( 9 / (2 ^ Int(Mid(randkey, 1, 1)))))

something like that and tell me how you have got it finally.

JD
     

0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860165
hey!!!

p = p & Int(Asc(j) + randkey - (9 / (2 ^ Int(Mid(randkey, 1, 1)))))

that works :)
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860184
Okie.
But things still doesnt work.

$number= &generate_serial_number('Brian Gaffie',51345561);
print $number . "\n";
print '95-160191165-29172935';

sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.


     #################### for testing
     $randkey = 95;
     ################## you override whatever is generated !!

     my $serial = $randkey . "-";

     my $p_value;

     $found = 0;
     for($i=0;$i<length($fullname);$i+=3)
     {
          #j = Mid(FullName, X1, 1)
          $j = substr($fullname,$i,1);

        $xx1 = ord(j);                    #         xx1 = Asc(j) 'get the ascii value of j
        $xx2 = $randkey;               ####     xx2 = randkey 'set xx2 to randkey
        $xx3 = 9;                              ####        xx3 = 9 'subtract 9
        $xx4 = 2;                              ####        xx4 = 2 'divide by 2
        $xx5 = int(substr($randkey,0,1)) ; ####        xx5 = Int(Mid(randkey, 1, 1)) 'get the first NUMBER in randkey
        $mthfunc = $xx1 + $xx2 - ( $xx3 / ($xx4 ** $xx5) ); ##        mthfunc = xx1 + xx2 - xx3 / xx4 ^ xx5 'do the math

         
         
        ####### I want to know what is the order ?? shall i power xx4 by xx5 and divide it by xx3 and then substract it from $xx1 + $xx2 ?
        #### How it shall be done ???
       $mth  = int($mthfunc);    ###mth = Int(mthfunc) 'int
         
          $p .= $mth; ###   p = p & mth 'APPEND NUMBER TO P, NOT ADD NUMBER
          if(length($p) > 6 and ! $found)
          {
               $p_value =$p;
               $found = 1;
          }


     }
     

     for($i=1;$i<=length($uniqueid);$i+=2)
     {
     #   jx = Mid(UniqueID, X2, 1)
          $jx = substr($uniqueid,$i,1);

          #jf = jf & Int(jx * randkey / 2 ** Int(Mid(randkey, 1, 1)) / 3 * randkey)
          $power = int(substr($randkey,1,1));
          $jf .=  int (   $jx * $randkey / 2 **$power  / 3 * $randkey );
     }
         

     $serial .= $p_value . '-' . $jf;
     return $serial;
}

This code doesnt work.
I guess ^ is used to raise the power right ?
In perl ^ is used for binary xor !!
I have corrected it, and actual operator is ** .

But still doesnt work.
Tell me value of xx1,xx2,xx3,xx4,xx5.

No matter what this needs to be solved.

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860199
im going to try to get some output, step by step, so we can compare and find out exactly what line the differences are occouring...
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6860205
That would be better. :)

JD
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860207
Okay i've got some output for you...here is what i used to generate the output...and the output its self...This code generated the serial properly...so here you go.


--VB CODE

randkey = 95
serial = randkey & "-"
Print #1, "Randkey: " & randkey
Print #1, "Starting FOR LOOP"
For X1 = 1 To Len(FullName) Step 3
    j = Mid(FullName, X1, 1)
    Print #1, "Current Letter: " & j
    xx1 = Asc(j) + randkey
    Print #1, "xx1=" & xx1
    xx2 = 2 ^ Int(Mid(randkey, 1, 1))
    Print #1, "xx2=" & xx2
    xx3 = xx1 - 9 / xx2
    Print #1, "xx3=" & xx3
    p = p & Int(xx3)
    Print #1, "p=" & p
    If Len(p) > 6 Then
        Exit For
    End If
Next X1
Close #1

--OUTPUT.TXT OUTPUT:

Randkey: 95
Starting FOR LOOP
Current Letter: B
xx1=161
xx2=512
xx3=160.982421875
p=160
Current Letter: a
xx1=192
xx2=512
xx3=191.982421875
p=160191
Current Letter: G
xx1=166
xx2=512
xx3=165.982421875
p=160191165


0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860365
Hey, I just had someone convert it to C++, if this helps you at all....I'm really trying to get this done in Perl...

-Brian


char * generateserialnumber(char *fullname, char *uniqueid, char * serial)
{
    long randkey, x1,x2,lval;
    char p[4096];
    char sval[4096];
    char stemp[80];
    char jf[80];
    char j, jx;

    double dval;

    *p = 0;
    *sval = 0;
    *stemp = 0;
    *jf = 0;
    srand( (unsigned) time(NULL) );
     
     do{
      randkey=rand() % 100;
    } while (randkey < 10);

    sprintf(serial, "%li-", randkey);
   
     for(x1=1; x1 <= (signed long) strlen(fullname); x1+=3)
    {
         j = fullname[x1 - 1];
         dval =  9 / pow(2,int(randkey/10));
         lval = int((double) j + randkey - dval);
         sprintf(sval,"%li",lval);
         strcat(p,sval);
         if (strlen(p) > 6)
              break;

    }

    for(x2=1; x2 <= (signed long) strlen(uniqueid); x2+=2)
    {
         jx = uniqueid[x2 - 1];
         if (jx >= '0' && jx <= '9')
         {
              dval = pow(2,randkey / 10);
              lval = int((double) (jx - '0') * randkey / dval /3 * randkey);
           }
         else
         {          
              sprintf(stemp,"%i", (int) jx);
              dval = pow(2,randkey / 10);
              lval = int( (double) randkey * (stemp[0] - '0') / dval);                    
           }        
         sprintf(sval,"%li",lval);
         strcat(jf,sval);
    }
    strcat(serial, p);
    strcat(serial, "-");
    strcat(serial, jf);
    return serial;
}
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6860503
Hey, I just had someone convert it to C++, if this helps you at all....I'm really trying to get this done in Perl...

-Brian


char * generateserialnumber(char *fullname, char *uniqueid, char * serial)
{
    long randkey, x1,x2,lval;
    char p[4096];
    char sval[4096];
    char stemp[80];
    char jf[80];
    char j, jx;

    double dval;

    *p = 0;
    *sval = 0;
    *stemp = 0;
    *jf = 0;
    srand( (unsigned) time(NULL) );
     
     do{
      randkey=rand() % 100;
    } while (randkey < 10);

    sprintf(serial, "%li-", randkey);
   
     for(x1=1; x1 <= (signed long) strlen(fullname); x1+=3)
    {
         j = fullname[x1 - 1];
         dval =  9 / pow(2,int(randkey/10));
         lval = int((double) j + randkey - dval);
         sprintf(sval,"%li",lval);
         strcat(p,sval);
         if (strlen(p) > 6)
              break;

    }

    for(x2=1; x2 <= (signed long) strlen(uniqueid); x2+=2)
    {
         jx = uniqueid[x2 - 1];
         if (jx >= '0' && jx <= '9')
         {
              dval = pow(2,randkey / 10);
              lval = int((double) (jx - '0') * randkey / dval /3 * randkey);
           }
         else
         {          
              sprintf(stemp,"%i", (int) jx);
              dval = pow(2,randkey / 10);
              lval = int( (double) randkey * (stemp[0] - '0') / dval);                    
           }        
         sprintf(sval,"%li",lval);
         strcat(jf,sval);
    }
    strcat(serial, p);
    strcat(serial, "-");
    strcat(serial, jf);
    return serial;
}
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6865011
sorry couldnt reply.
i was bit too occupied @ office.
i shall try something @ home and let you know,
JD
0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 100 total points
ID: 6874430
See this works.

$number= &generate_serial_number('Brian Gaffie',51345561);

print "\n\n\n";

print $number . "\n";
print '95-160191165-29172935';

sub generate_serial_number
{
     my($fullname,$uniqueid) = @_;

     my $randkey = int(rand(99)) + 10; #adding 10 would make sure that randkey is minimum 2 digits.


     #################### for testing
     $randkey = 95;
     ################## you override whatever is generated !!

     my $serial = $randkey . "-";

     my $p_value;

     $found = 0;

     for($i=1;$i<length($fullname) - 2 ;$i+=3)
     {

          $j = substr($fullname,$i-1,1);
          print "Current letter $j" . "\n" ;;

          $xx1 = ord($j) + $randkey;
          print "XX1 = $xx1\n";

          $xx2 = 2 ** int(substr($randkey,0,1));

          print "XX2 = $xx2\n";

          $xx3 = $xx1 - 9 / $xx2;

          print "XX3 = $xx3\n";

          $p = $p . int($xx3);
          print "P is $p \n";
          if(length($p) > 6 and ! $found)
          {
               $p_value =$p;
               $found = 1;
          }


     }
     

     for($i=1;$i<=length($uniqueid);$i+=2)
     {

          $jx = substr($uniqueid,$i,1);
          $power = int(substr($randkey,1,1));
          $jf .=  int (   $jx * $randkey / 2 **$power  / 3 * $randkey );
     }
         

     $serial .= $p_value . '-' . $jf;
     return $serial;
}


Now the second part that is to find value of $jf still doesnt work. Can you give me similar output of variable at each step like you did for 1st loop ?

Then it can be done for sure.
JD
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6977217
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if they are still open in 14 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20249647.html
http://www.experts-exchange.com/questions/Q.20252182.html
http://www.experts-exchange.com/questions/Q.20276179.html
http://www.experts-exchange.com/questions/Q.20281492.html
http://www.experts-exchange.com/questions/Q.20281343.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @14 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7114039
Your response to these requests is very much appreciated.
:) Moondancer - EE Moderator
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now