In perl, $foo is called a scalar, it holds one and only one value.
To store more than one of something, you need an array. So
#!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); sub Main { my @Solutions; ... push @Solutions, Solution( $t, $i, $A, $B ); ... print join "\n", "Top 100:", @Solutions[ 0 .. 99 ]; } sub Solution { my( $t, $i, $A, $B ) = @_; my $result = $t / $i / $A / $B + "yada yada yada"; return $result; }
more on this in perlintro, the basic datatypes, three, Arrays: A Tutorial/Reference, Lexical scoping like a fox, Read this if you want to cut your development time in half! and understand that strict itself confers no benefits; The benefits come from avoidance of the bad practices forbidden by strict :)
See also abs
In reply to Re: Expecting a 100 solutions, getting just 1
by Anonymous Monk
in thread Expecting a 100 solutions, getting just 1
by doozy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |