re-arranged a bit
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Sat, 29 Oct 2011 21:48:44 +0200
changeset 2 22e93ecd595f
parent 1 4a09ca723f56
child 3 1519d83aa83b
re-arranged a bit
prime
--- a/prime	Sat Oct 29 21:48:29 2011 +0200
+++ b/prime	Sat Oct 29 21:48:44 2011 +0200
@@ -6,26 +6,22 @@
 use strict;
 use warnings;
 use File::Basename;
-#use Smart::Comments;
+
 #use diagnostics;
 
 my $ME = basename $0;
 
-#n: ist die Zahl aus der die sämtlichen Primzahlen gefiltert wird
-#i: Primzahl: diese wird durch n geteilt
-
-my $number = $ARGV[0];
-
 if (not @ARGV) {
     # FIXME: be more verbose
     die "$ME: Sorry, need the number\n";
 }
 
+my $number = $ARGV[0];
+
 #1. find all divisors of $number
 my @divisors = findDivisors($number);
 
 #2. delete all non primes
-
 my @primes = ();
 
 #for each element in array divisors
@@ -37,17 +33,17 @@
     #determine length of subprimes and save in noOfDivisors
     my $noOfDivisors = scalar(@subprimes);
 
-    #
     if ($noOfDivisors == 0) {@primes = (@primes, $div); }
 }
 
 #print"Die Teile von $number sind: ".join(", ", @divisors)."\n";
 #print"Die Primzahlteile von $number sind: ".join(", ", @primes)."\n";
 
-my @xxx = xxx($number, @primes);
+# not sure about the name of the function! // .hs
+@primes = factorize($number, @primes);
 
-if (@xxx) {
-    print join("*", @xxx), "\n"; 
+if (@primes) {
+    print join("*", @primes), "\n"; 
 }
 else {
     #print STDERR "Sorry, $number is prime itself!\n";
@@ -73,7 +69,7 @@
     return @divisors;
 }
 
-sub xxx {
+sub factorize {
     my $current = shift @_;
     my @primes = @_;