On Wednesday 25 February 2004 21:52, Joel generously enriched virtual reality 
by making up this one:

Hi, 

> Is there an et cetera type command in perl? Specifically, what I want to do
> is to go from

is there an etc command in any other programing language? 

>
> 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?
>

What about this one:

---snip---

#! /usr/bin/perl

use strict;
use warnings;

my @numarray=qw/2 6 13 18 24 33 120/;

foreach (@numarray){
  print "\nMODing $_: ";
  for (my $i=1; $i>0;$i++){
    print "$i ";
    print " doesnt MOD it." and last if ($_ % $i != 0);
    print "MODs ";
  }
}
print "\n";


---snap---

prints 

---snip---

#~> ./mod.pl

MODing 2: 1 MODs 2 MODs 3  doesnt MOD it.
MODing 6: 1 MODs 2 MODs 3 MODs 4  doesnt MOD it.
MODing 13: 1 MODs 2  doesnt MOD it.
MODing 18: 1 MODs 2 MODs 3 MODs 4  doesnt MOD it.
MODing 24: 1 MODs 2 MODs 3 MODs 4 MODs 5  doesnt MOD it.
MODing 33: 1 MODs 2  doesnt MOD it.
MODing 120: 1 MODs 2 MODs 3 MODs 4 MODs 5 MODs 6 MODs 7  doesnt MOD it.

---snap---

on my box.

Is that what you want?
May I ask what you are planning to do?

Enjoy, Wolf


-- 
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