my $f1; my $c = <>; # get number # Get first factor ($f1,$c) = get_a_factor($c); print $f1; # Get rest of 'em while ($c > 1) { ($f1,$c) = get_a_factor($c); print ", $f1"; } print "\n"; sub get_a_factor { my $num = shift; ... compute factor ... return ($factor, $num/$factor); }