>>5
I did this in 5 minutes.
########################
sub factor(){
my ($inputNumber) = @_;
my @outputFactors = ();
my @potentialFactors = (2..$inputNumber);
foreach my $currentPotentialFactor ( @potentialFactors ){
unless( $inputNumber % $currentPotentialFactor ){
push(@outputFactors, $currentPotentialFactor);
}
}
return \@outputFactors;
}
###########################
Mine works, yours doesn't, by the way. Good luck trying to debug that awful POS code you wrote - which is pretty much the antithesis of elegant. If it worked, it might be classified as interesting, but not elegant. Plus you are raping the map builtin. Map returns a list, which you aren't using, and is (and should always be) used as a way to transform one list into another, taking a coderef as the transformation algorithm. You are bastardizing it into a strange looping construct because its "neat". For, and Foreach, are both far better suited to this task - and document this to the reader of your code much better.
Always write your code with the belief that the next person to have your job will be a raging psychopath with a gun, who knows where you life. Pray I never work with you in the professional world.