LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-05-2012, 11:20 AM   #1
emanWASUNAVAILABLE
LQ Newbie
 
Registered: Nov 2012
Location: behind one of 9 terminals
Distribution: backtrack
Posts: 3

Rep: Reputation: Disabled
Post 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++;

}
 
Old 11-06-2012, 04:23 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 651

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

Quote:
Originally Posted by emanWASUNAVAILABLE View Post
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.

Last edited by millgates; 11-07-2012 at 03:01 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl: how to save an e-mail attachment on disk keeping the "&" character (no "%26"!!) d1s4st3r Programming 5 09-29-2010 09:30 PM
Perl - Can't use string ("html") as an ARRAY ref while "strict refs" OldGaf Programming 9 08-11-2009 11:14 AM
"Failed Dependency error" while installing RPM for "DateTime" perl modules giridhargopal.cj Linux - Newbie 7 11-19-2008 12:05 AM
PERL: Help w/ "foreach" loops and building a Crontab entry - Just need some advice bpmee Programming 5 10-13-2006 02:12 PM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration