LinuxQuestions.org

LinuxQuestions.org (http://www.linuxquestions.org/questions/index.php)
-   Programming (http://www.linuxquestions.org/questions/forumdisplay.php?f=9)
-   -   Perl "wepster", need advice! (http://www.linuxquestions.org/questions/showthread.php?t=4175435746)

emanWASUNAVAILABLE 11-05-2012 11:20 AM

Perl "wepster", need advice!
 
Hello, my name is eman =)
I havent included the rest of the program for obvious reasons and this source code is ment for educational purposes only!

I wrote this because I am going to college for network administration and am currently studying perl and 802.11. Obviously I havent included any system calls because this isnt ment for script kiddies but for gurus to help me figure out an issue I'm having with it.

The script runs fine but the problem is that its only running @ 40%cpu and 0% ram. Ive read that perl is finiky about how you use what forms of operators and in what context. Is there any way to boost the performance of this program so I dont have to wait 10 days for it to finish?



#!/usr/bin/perl

# wepster by eman

@alpha1 = qw( a b c d e f g h i j k l m n o p q r s t u v w x y z);
@alpha2 = qw( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
@alpha3 = qw( 0 1 2 3 4 5 6 7 8 9 );

$key1 = 10;
$key2 = 26;
$key3 = 58;

@whatami1 = @alpha1;
@whatami2 = @alpha1;
@whatami3 = @alpha1;
@whatami4 = @alpha1;
@whatami5 = @alpha1;
@whatami6 = @alpha1;
@whatami7 = @alpha1;
@whatami8 = @alpha1;
@whatami9 = @alpha1;
@whatami10 = @alpha1;

$count = 1;

# if ($key == $key1)

while ($count <= 8)
{
foreach $temp (@whatami1) {
foreach $temp2 (@whatami2) {
foreach $temp3 (@whatami3) {
foreach $temp4 (@whatami4) {
foreach $temp5 (@whatami5) {
foreach $temp6 (@whatami6) {
foreach $temp7 (@whatami7) {
foreach $temp8 (@whatami8) {
foreach $temp9 (@whatami9) {
foreach $temp10 (@whatami10) {
print "$temp$temp2$temp3$temp4$temp5$temp6$temp7$temp8$temp9$temp10\n";
}
}
}
}
}
}
}
}
}
}

# 1

if ( $count == 1 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;
}

# make first letter number

if ( $count == 2 ) {
splice @whatami1, 0;
@whatami1 = @alpha3;
}

# 2

if ( $count == 3 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;
}

# make second letter number

if ( $count == 4 ) {
splice @whatami2, 0;
@whatami2 = @alpha3;
}

# make first letter number

if ( $count == 5 ) {
splice @whatami1, 0;
@whatami1 = @alpha3;
}

# make first letter lowercase
# make second letter capital

if ( $count == 6 ) {
splice @whatami1, 0;
@whatami1 = @alpha1;

splice @whatami2, 0;
@whatami2 = @alpha2;
}

# make second letter number

if ( $count == 7 ) {
splice @whatami2, 0;
@whatami2 = @alpha3;
}

# 3 make them all uppercase

if ( $count == 8 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;
}

# so on and so forth
#
# 4

if ( $count == 8 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;
}

# 5

if ( $count == 8 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;
}

# 6

if ( $count == 9 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;

splice @whatami6, 0;
@whatami6 = @alpha2;
}

# 7

if ( $count == 9 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;

splice @whatami6, 0;
@whatami6 = @alpha2;

splice @whatami7, 0;
@whatami7 = @alpha2;
}

# 8

if ( $count == 9 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;

splice @whatami6, 0;
@whatami6 = @alpha2;

splice @whatami7, 0;
@whatami7 = @alpha2;

splice @whatami8, 0;
@whatami8 = @alpha2;
}

# 9

if ( $count == 9 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;

splice @whatami6, 0;
@whatami6 = @alpha2;

splice @whatami7, 0;
@whatami7 = @alpha2;

splice @whatami8, 0;
@whatami8 = @alpha2;

splice @whatami9, 0;
@whatami9 = @alpha2;
}

# 10

if ( $count == 9 ) {
splice @whatami1, 0;
@whatami1 = @alpha2;

splice @whatami2, 0;
@whatami2 = @alpha2;

splice @whatami3, 0;
@whatami3 = @alpha2;

splice @whatami4, 0;
@whatami4 = @alpha2;

splice @whatami5, 0;
@whatami5 = @alpha2;

splice @whatami6, 0;
@whatami6 = @alpha2;

splice @whatami7, 0;
@whatami7 = @alpha2;

splice @whatami8, 0;
@whatami8 = @alpha2;

splice @whatami9, 0;
@whatami9 = @alpha2;

splice @whatami10, 0;
@whatami10 = @alpha2;
}
$count++;

}

millgates 11-06-2012 04:23 AM

Hi, I am no expert on perl, but
1) please use the [code][/code] tags around your code.

Quote:

Originally Posted by emanWASUNAVAILABLE (Post 4822725)
The script runs fine but the problem is that its only running @ 40%cpu and 0% ram.

then perhaps neither the memory nor the cpu are the bottlenecks of your program.

Code:

@alpha1 = qw( a b c d e f g h i j k l m n o p q r s t u v w x y z);

@whatami1 = @alpha1;
@whatami2 = @alpha1;
@whatami3 = @alpha1;
@whatami4 = @alpha1;
@whatami5 = @alpha1;
@whatami6 = @alpha1;
@whatami7 = @alpha1;
@whatami8 = @alpha1;
@whatami9 = @alpha1;
@whatami10 = @alpha1;
{
  foreach $temp (@whatami1) {
    foreach $temp2 (@whatami2) {
      foreach $temp3 (@whatami3) {
        foreach $temp4 (@whatami4) {
          foreach $temp5 (@whatami5) {
            foreach $temp6 (@whatami6) {
              foreach $temp7 (@whatami7) {
                foreach $temp8 (@whatami8) {
                  foreach $temp9 (@whatami9) {
                    foreach $temp10 (@whatami10) {
                      print "$temp$temp2$temp3$temp4$temp5$temp6$temp7$temp8$temp9$temp10\n";
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

wow, that looks pretty scary :) do you realize how much data it prints? It's like 11*26^10 bytes (that's more than 1400 TB). I don't know where you're printing it to but I can imagine it takes a lot of time.


All times are GMT -5. The time now is 01:38 PM.