Joel wrote:
> Is there an et cetera type command in perl? Specifically, what I want
> to do is to go from
> 
> while (1) {
>     my $num = shift @numarray;
>     if ($num % 2==0) {
> 
> and if the modulus of 2 is 0, find the modulus of 3 and so on. Can
> anyone give me some suggestions?
        Uncertain exactly what you are asking for Joel, but here is a starting point:

#!perl -w

use strict;

my @numarray = qw(1 2 3 4 6 8 10 15 20);

my $MyMod ;
my $MyLastSuccessMod ;

while (1) {
    my $num = shift @numarray;
    last if ( ! defined $num );
    $MyLastSuccessMod = -1;
    $MyMod = 2;
    while ( ! ($num % $MyMod) ) {
        $MyLastSuccessMod = $MyMod++;
     }
    if ( $MyLastSuccessMod < 0 ) {
        print "No valid modulus for this number: " . $num . "\n";
     }else {
        printf "Modulus went up through number : %d/%d\n",
                                $MyLastSuccessMod,
                                $num;
     }
 }
Output:
No valid modulus for this number: 1
Modulus went up through number : 2/2
No valid modulus for this number: 3
Modulus went up through number : 2/4
Modulus went up through number : 3/6
Modulus went up through number : 2/8
Modulus went up through number : 2/10
No valid modulus for this number: 15
Modulus went up through number : 2/20

        Like I said, uncsure of exact request, but will continue as lone as the Mod 
comes out zero on a number.
> 
> Thanks,
> 
> Joel



      Any questions and/or problems, please let me know.

      Thanks.

Wags ;)
Int: 9-8-002-2224
Ext: 408-323-4225x2224



**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to